Skip to content

Fix comparison of numeric jsonb columns #22

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

Merged
merged 3 commits into from
Aug 7, 2024
Merged

Conversation

erikdubbelboer
Copy link
Member

@erikdubbelboer erikdubbelboer commented Aug 5, 2024

Since we use ->> on jsonb fields we always get a string back. Comparisons such as < and > were done on string values which gives unexpected results.

I have tried various other approaches that failed.

  • Casting everything to a jsonb doesn't work because you can't cast query params to jsonb.
  • Using a CASE WHEN with jsonb_typeof doesn't work because each WHEN of a CASE WHEN needs to return the same type.
  • There are also complications with calling Convert recursively for $elemMatch where you then don't know the column type anymore.

Since we use ->> on jsonb fields we always get a string back.
Comparisons such as < and > were done on string values which gives
unexpected results.
@erikdubbelboer erikdubbelboer merged commit 9ed74d2 into main Aug 7, 2024
5 checks passed
@erikdubbelboer erikdubbelboer deleted the fix-numeric-compare branch August 7, 2024 12:38
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