Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add mods to fields, specifically for "lower(field)" in SQL #92

Merged
merged 1 commit into from
Jul 26, 2023

Conversation

peterbroadhurst
Copy link
Contributor

@peterbroadhurst peterbroadhurst commented Jul 25, 2023

Have a microservice with a requirement to use lower(address) function on query filters against the DB, in order to work with a PostgreSQL index on lower(address). This allows efficient indexed query, using case insensitive searches (for example using the checksumed Eth address).

With this PR, it should be as simple as:

"address": &ffapi.StringFieldLower{},

Signed-off-by: Peter Broadhurst <peter.broadhurst@kaleido.io>
@codecov-commenter
Copy link

Codecov Report

Merging #92 (8c28b1d) into main (992357b) will not change coverage.
The diff coverage is 100.00%.

@@            Coverage Diff            @@
##              main       #92   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           63        63           
  Lines         4885      4905   +20     
=========================================
+ Hits          4885      4905   +20     
Files Changed Coverage Δ
pkg/dbsql/filter_sql.go 100.00% <100.00%> (ø)
pkg/ffapi/filter.go 100.00% <100.00%> (ø)
pkg/ffapi/query_fields.go 100.00% <100.00%> (ø)

Copy link
Contributor

@nguyer nguyer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! It did take me a minute to figure out that fmt.Sprintf("lower(%s)", fieldName) was not a way for Go to lowercase the string, but for the DB to lowercase the string 🙃 Need more coffee still.

@nguyer nguyer merged commit 51b218b into main Jul 26, 2023
@nguyer nguyer deleted the lower-fields branch July 26, 2023 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants