updated changelog and exposed search.TokenFunctions

This commit is contained in:
Gani Georgiev
2025-04-15 12:24:13 +03:00
parent 46186f84f0
commit bf9a7b1e3d
4 changed files with 14 additions and 12 deletions
+1 -1
View File
@@ -305,7 +305,7 @@ func resolveToken(token fexpr.Token, fieldResolver FieldResolver) (*ResolverResu
Params: dbx.Params{placeholder: cast.ToFloat64(token.Literal)},
}, nil
case fexpr.TokenFunction:
fn, ok := tokenFunctions[token.Literal]
fn, ok := TokenFunctions[token.Literal]
if !ok {
return nil, fmt.Errorf("unknown function %q", token.Literal)
}
+2 -2
View File
@@ -6,12 +6,12 @@ import (
"github.com/ganigeorgiev/fexpr"
)
var tokenFunctions = map[string]func(
var TokenFunctions = map[string]func(
argTokenResolverFunc func(fexpr.Token) (*ResolverResult, error),
args ...fexpr.Token,
) (*ResolverResult, error){
// geoDistance(lonA, latA, lonB, latB) calculates the Haversine
// distance between 2 coordinates in kilometres (https://www.movable-type.co.uk/scripts/latlong.html).
// distance between 2 points in kilometres (https://www.movable-type.co.uk/scripts/latlong.html).
//
// The accepted arguments at the moment could be either a plain number or a column identifier (including NULL).
// If the column identifier cannot be resolved and converted to a numeric value, it resolves to NULL.
+2 -2
View File
@@ -20,7 +20,7 @@ func TestTokenFunctionsGeoDistance(t *testing.T) {
}
defer testDB.Close()
fn, ok := tokenFunctions["geoDistance"]
fn, ok := TokenFunctions["geoDistance"]
if !ok {
t.Error("Expected geoDistance token function to be registered.")
}
@@ -173,7 +173,7 @@ func TestTokenFunctionsGeoDistanceExec(t *testing.T) {
}
defer testDB.Close()
fn, ok := tokenFunctions["geoDistance"]
fn, ok := TokenFunctions["geoDistance"]
if !ok {
t.Error("Expected geoDistance token function to be registered.")
}