Skip to content

Instantly share code, notes, and snippets.

@tylerhunt
Created January 22, 2024 19:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tylerhunt/326452e326126a42d14732662c640232 to your computer and use it in GitHub Desktop.
Save tylerhunt/326452e326126a42d14732662c640232 to your computer and use it in GitHub Desktop.
Using PostgreSQL's `?` jsonb operator with Active Record
# 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