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

Question: Add exists_all/exists_any for jsonb/hstore columns #72

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

elcuervo
Copy link

Implements some other operations from https://www.postgresql.org/docs/9.4/functions-json.html#FUNCTIONS-JSONB-OP-TABLE

First of all thank you for your work on the gem.
We use it extensively and it's fantastic.

From time to time I want to check if a jsonb column has a given set of keys (we use some of them to
enable and disable features)

This is just an initial idea. The AREL build is far from elegant but I wanted to get your feedback
about the concept.

My AREL-fu is not too strong so feel free to correct anything that looks weird.

if [:hstore, :jsonb].include?(column.type)
kind.new(arel.left, arel.right)
else
raise ArgumentError.new("Invalid argument for .where.#{kind}(), got #{arel.class}")
Copy link
Author

Choose a reason for hiding this comment

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

This is not user friendly (kind is a ruby class) but just leaving it here.
If the feature makes sense some cleanup and documentation should be added as well :)

@GeorgeKaraszi
Copy link
Owner

@elcuervo Hey sorry for the radio silence. I've been sitting on this for a while and wanted to first get out my autoloader changes before spearheading into new functionality. Now that it has been pushed out if you could realign your branch I can take a fresh look into this addition 👍 .

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.

None yet

2 participants