@@ -108,47 +108,11 @@ func findMockSourceError(errors []errorWithPath) string {
108108 }
109109 }
110110
111- // Look for missing filter error (array source with type: one without filter)
112- for _ , e := range errors {
113- if ! isMockPath (e .path ) {
114- continue
115- }
116-
117- if req , ok := e .err .ErrorKind .(* kind.Required ); ok {
118- if slices .Contains (req .Missing , "filter" ) {
119- if usedSource := findUsedArraySource (errors , e .path ); usedSource != "" {
120- parentPath := getParentPath (e .path )
121- return fmt .Sprintf ("at '%s': type 'one' with '%s' source requires 'filter' to select a single row" ,
122- formatPath (parentPath ), usedSource )
123- }
124- }
125- }
126- }
127-
128- // Look for multiple sources error
129- for _ , e := range errors {
130- if ! isMockPath (e .path ) {
131- continue
132- }
133-
134- if addl , ok := e .err .ErrorKind .(* kind.AdditionalProperties ); ok {
135- if len (addl .Properties ) > 1 {
136- parentPath := getParentPath (e .path )
137- return fmt .Sprintf ("at '%s': mock must have exactly one source, found multiple: %s" ,
138- formatPath (parentPath ), strings .Join (addl .Properties , ", " ))
139- }
140- }
141- }
142-
143111 return ""
144112}
145113
146114// formatMockSourceMismatchError creates a helpful message for source/type mismatches.
147115func formatMockSourceMismatchError (parentPath string , typeName string , invalidSources []string ) string {
148- if len (invalidSources ) == 0 {
149- return ""
150- }
151-
152116 source := invalidSources [0 ]
153117
154118 // Check if multiple sources
@@ -157,7 +121,7 @@ func formatMockSourceMismatchError(parentPath string, typeName string, invalidSo
157121 formatPath (parentPath ), strings .Join (invalidSources , ", " ))
158122 }
159123
160- // type: one with array source ( without filter - but we should have caught this above)
124+ // type: one with array source without filter
161125 if typeName == "one" && isArraySource (source ) {
162126 return fmt .Sprintf ("at '%s': type 'one' with '%s' requires 'filter' to select a single row, or use object/object_js for a single object" ,
163127 formatPath (parentPath ), source )
@@ -169,13 +133,7 @@ func formatMockSourceMismatchError(parentPath string, typeName string, invalidSo
169133 formatPath (parentPath ), source )
170134 }
171135
172- // type: none with mock
173- if typeName == "none" {
174- return fmt .Sprintf ("at '%s': type 'none' does not support mock - use 'sql' instead" ,
175- formatPath (parentPath ))
176- }
177-
178- // Generic message
136+ // Generic message for other cases
179137 return fmt .Sprintf ("at '%s': invalid mock source '%s' for type '%s'" ,
180138 formatPath (parentPath ), source , typeName )
181139}
@@ -235,22 +193,6 @@ func isTypeNone(errors []errorWithPath, parentPath string) bool {
235193 return foundOne && foundMany
236194}
237195
238- // findUsedArraySource finds which array source was used from error messages.
239- func findUsedArraySource (errors []errorWithPath , mockPath string ) string {
240- for _ , e := range errors {
241- if e .path == mockPath {
242- if addl , ok := e .err .ErrorKind .(* kind.AdditionalProperties ); ok {
243- for _ , prop := range addl .Properties {
244- if isArraySource (prop ) {
245- return prop
246- }
247- }
248- }
249- }
250- }
251- return ""
252- }
253-
254196// isSqlMockOneOfError checks if the oneOf error is specifically about sql/mock.
255197func isSqlMockOneOfError (err * jsonschema.ValidationError ) bool {
256198 if err == nil {
0 commit comments