diff --git a/backend/pkg/database/odatasql/query.go b/backend/pkg/database/odatasql/query.go index 54cad94e3..3f25e9796 100644 --- a/backend/pkg/database/odatasql/query.go +++ b/backend/pkg/database/odatasql/query.go @@ -493,7 +493,7 @@ func buildWhereFromFilter(source string, node *godata.ParseNode) (string, error) default: return query, fmt.Errorf("unsupported token type") } - query = fmt.Sprintf("%s -> '$.%s' LIKE '%s'", source, queryPath, value) + query = fmt.Sprintf("%s ->> '%s' LIKE '%s'", source, queryPath, value) } return query, nil diff --git a/backend/pkg/database/odatasql/query_test.go b/backend/pkg/database/odatasql/query_test.go index 9d3c4c04e..8ea4fa3a4 100644 --- a/backend/pkg/database/odatasql/query_test.go +++ b/backend/pkg/database/odatasql/query_test.go @@ -561,6 +561,20 @@ func TestBuildSQLQuery(t *testing.T) { }, want: []Car{car1}, }, + { + name: "'startswith' filter", + args: args{ + filterString: PointerTo(fmt.Sprintf("startswith(Manufacturer/Id, '%s')", manu1.ID[0:3])), + }, + want: []Car{car1, car2}, + }, + { + name: "'endswith' filter", + args: args{ + filterString: PointerTo("endswith(ModelName, '3')"), + }, + want: []Car{car3}, + }, { name: "filter on nested field", args: args{