updated changelog and exposed search.TokenFunctions
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user