You've already forked pocketbase
							
							
				mirror of
				https://github.com/pocketbase/pocketbase.git
				synced 2025-10-31 16:47:43 +02:00 
			
		
		
		
	added more geoPoint field acccess tests
This commit is contained in:
		| @@ -170,7 +170,7 @@ func TestImportCollections(t *testing.T) { | ||||
| 				expectedCollectionFields := map[string]int{ | ||||
| 					core.CollectionNameAuthOrigins: 6, | ||||
| 					"nologin":                      10, | ||||
| 					"demo1":                        18, | ||||
| 					"demo1":                        19, | ||||
| 					"demo2":                        5, | ||||
| 					"demo3":                        5, | ||||
| 					"demo4":                        16, | ||||
|   | ||||
| @@ -419,8 +419,8 @@ func (r *runner) processActiveProps() (*search.ResolverResult, error) { | ||||
| 			return nil, fmt.Errorf("non-filterable field %q", prop) | ||||
| 		} | ||||
|  | ||||
| 		// json field -> treat the rest of the props as json path | ||||
| 		// @todo consider converting to "JSONExtractable" interface | ||||
| 		// json or geoPoint field -> treat the rest of the props as json path | ||||
| 		// @todo consider converting to "JSONExtractable" interface with optional extra validation for the remaining props? | ||||
| 		if field != nil && (field.Type() == FieldTypeJSON || field.Type() == FieldTypeGeoPoint) { | ||||
| 			var jsonPath strings.Builder | ||||
| 			for j, p := range r.activeProps[i+1:] { | ||||
|   | ||||
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
										
											Binary file not shown.
										
									
								
							| @@ -291,6 +291,15 @@ var filterFunctions = map[string]func( | ||||
| 	}, | ||||
| } | ||||
|  | ||||
| var normalizedIdentifiers = map[string]string{ | ||||
| 	// if `null` field is missing, treat `null` identifier as NULL token | ||||
| 	"null": "NULL", | ||||
| 	// if `true` field is missing, treat `true` identifier as TRUE token | ||||
| 	"true": "1", | ||||
| 	// if `false` field is missing, treat `false` identifier as FALSE token | ||||
| 	"false": "0", | ||||
| } | ||||
|  | ||||
| func resolveToken(token fexpr.Token, fieldResolver FieldResolver) (*ResolverResult, error) { | ||||
| 	switch token.Type { | ||||
| 	case fexpr.TokenIdentifier: | ||||
| @@ -313,19 +322,11 @@ func resolveToken(token fexpr.Token, fieldResolver FieldResolver) (*ResolverResu | ||||
| 		// custom resolver | ||||
| 		// --- | ||||
| 		result, err := fieldResolver.Resolve(token.Literal) | ||||
|  | ||||
| 		// @todo replace with strings.EqualFold | ||||
| 		if err != nil || result.Identifier == "" { | ||||
| 			m := map[string]string{ | ||||
| 				// if `null` field is missing, treat `null` identifier as NULL token | ||||
| 				"null": "NULL", | ||||
| 				// if `true` field is missing, treat `true` identifier as TRUE token | ||||
| 				"true": "1", | ||||
| 				// if `false` field is missing, treat `false` identifier as FALSE token | ||||
| 				"false": "0", | ||||
| 			} | ||||
| 			if v, ok := m[strings.ToLower(token.Literal)]; ok { | ||||
| 				return &ResolverResult{Identifier: v}, nil | ||||
| 			for k, v := range normalizedIdentifiers { | ||||
| 				if strings.EqualFold(k, token.Literal) { | ||||
| 					return &ResolverResult{Identifier: v}, nil | ||||
| 				} | ||||
| 			} | ||||
| 			return nil, err | ||||
| 		} | ||||
| @@ -346,13 +347,13 @@ func resolveToken(token fexpr.Token, fieldResolver FieldResolver) (*ResolverResu | ||||
| 			Params:     dbx.Params{placeholder: cast.ToFloat64(token.Literal)}, | ||||
| 		}, nil | ||||
| 	case fexpr.TokenFunction: | ||||
| 		f, ok := filterFunctions[token.Literal] | ||||
| 		fn, ok := filterFunctions[token.Literal] | ||||
| 		if !ok { | ||||
| 			return nil, fmt.Errorf("unknown function %q", token.Literal) | ||||
| 		} | ||||
|  | ||||
| 		args, _ := token.Meta.([]fexpr.Token) | ||||
| 		return f(func(argToken fexpr.Token) (*ResolverResult, error) { | ||||
| 		return fn(func(argToken fexpr.Token) (*ResolverResult, error) { | ||||
| 			return resolveToken(argToken, fieldResolver) | ||||
| 		}, args...) | ||||
| 	} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user