Created
January 22, 2024 19:36
-
-
Save tylerhunt/326452e326126a42d14732662c640232 to your computer and use it in GitHub Desktop.
Using PostgreSQL's `?` jsonb operator with Active Record
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# PostgreSQL’s question mark (`?`) jsonb operator can pose an issue when using | |
# Active Record, since `?` is used to denote bind variable substitution. One | |
# way to work around this is to use named bind variable substitution with a | |
# hash instead. | |
Entity.where('metadata ? :key', key: 'profile_url') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment