udpated :lower modifier to apply after all other normalizations

This commit is contained in:
Gani Georgiev
2024-12-06 22:09:29 +02:00
parent 6a4e04533c
commit c91d889da3
4 changed files with 18 additions and 21 deletions

View File

@@ -680,21 +680,6 @@ func (r *runner) processLastProp(collection *Collection, prop string) (*search.R
cleanFieldName := inflector.Columnify(field.GetName())
// field with ":lower" modifier
// -------------------------------------------------------
if modifier == lowerModifier {
result := &search.ResolverResult{
Identifier: "LOWER([[" + r.activeTableAlias + "." + cleanFieldName + "]])",
}
if r.withMultiMatch {
r.multiMatch.valueIdentifier = "LOWER([[" + r.multiMatchActiveTableAlias + "." + cleanFieldName + "]])"
result.MultiMatchSubQuery = r.multiMatch
}
return result, nil
}
// arrayable fields with ":length" modifier
// -------------------------------------------------------
if modifier == lengthModifier && isMultivaluer {
@@ -747,11 +732,11 @@ func (r *runner) processLastProp(collection *Collection, prop string) (*search.R
// default
// -------------------------------------------------------
result := &search.ResolverResult{
Identifier: fmt.Sprintf("[[%s.%s]]", r.activeTableAlias, cleanFieldName),
Identifier: "[[" + r.activeTableAlias + "." + cleanFieldName + "]]",
}
if r.withMultiMatch {
r.multiMatch.valueIdentifier = fmt.Sprintf("[[%s.%s]]", r.multiMatchActiveTableAlias, cleanFieldName)
r.multiMatch.valueIdentifier = "[[" + r.multiMatchActiveTableAlias + "." + cleanFieldName + "]]"
result.MultiMatchSubQuery = r.multiMatch
}
@@ -777,5 +762,13 @@ func (r *runner) processLastProp(collection *Collection, prop string) (*search.R
}
}
// account for the ":lower" modifier
if modifier == lowerModifier {
result.Identifier = "LOWER(" + result.Identifier + ")"
if r.withMultiMatch {
r.multiMatch.valueIdentifier = "LOWER(" + r.multiMatch.valueIdentifier + ")"
}
}
return result, nil
}