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

Jsonb Selectors #82

Open
rainerborene opened this issue Oct 30, 2017 · 2 comments
Open

Jsonb Selectors #82

rainerborene opened this issue Oct 30, 2017 · 2 comments

Comments

@rainerborene
Copy link

rainerborene commented Oct 30, 2017

@rzane what do you think about supporting jsonb selectors?
https://www.postgresql.org/docs/9.4/static/functions-json.html

Some ideias:

select data->>'completed_at' ...

which translates to

scope.selecting { data.completed_at }

Related discussions:
rails/arel#288

@rainerborene
Copy link
Author

I'll be using this monkey patch until not having this feature implemented.

BabySqueel::Operators::Generic.module_eval do
  def json(name)
    op '->>', Arel::Nodes.build_quoted(name)
  end
end

# now i can do this
Activity.selecting { data.json(:name).eq('xzy') }

@rzane
Copy link
Owner

rzane commented Oct 31, 2017

Great idea, but, I'd rather have a separate package implement JSON types and simply integrate it here. That way, users who don't use BabySqueel could reap the benefits as well. Does that make sense?

Related: rails/arel#288

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

No branches or pull requests

2 participants