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

Use Arel::Nodes::BindParam in Oracle visitor for queries using both LIMIT and OFFSET #450

Merged
merged 1 commit into from
Oct 7, 2016

Conversation

roooodcastro
Copy link

This is to fix #438, where the Oracle visitor is raising an undefined method error when trying to calculate the limit for queries specifying both limit and offset.

Since this commit, ActiveModel now uses BindParams to pass limit and offset parameters to Arel, so it now isn't able to calculate the limit directly.

In this fix, when a BindParam object is passed to visit_Arel_Nodes_SelectStatement, it now will use this binding instead of calculating the values. The previous behaviour remains when the offset expression is not a BindParam object.

@rails-bot
Copy link

Thanks for the pull request, and welcome! The Rails team is excited to review your changes, and you should hear from @rafaelfranca (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@rafaelfranca rafaelfranca merged commit 3eddc2f into rails:master Oct 7, 2016
rafaelfranca added a commit that referenced this pull request Oct 7, 2016
Use Arel::Nodes::BindParam in Oracle visitor for queries using both LIMIT and OFFSET
@rafaelfranca
Copy link
Member

Backported in 8813ad8

yahonda added a commit to yahonda/oracle-enhanced that referenced this pull request Oct 11, 2016
rails/arel@8813ad8

Also Refer
rails/arel#450
rails/arel#438
rsim#848

This fix itself has been available since Arel 7.1.3
but the latest version of Arel is 7.1.4.
yahonda added a commit to yahonda/oracle-enhanced that referenced this pull request Nov 3, 2016
…index:: 3:`

when `offset` and `limit` used at the same time with JRuby and Oracle 11gR2 or lower

since rails/arel#450 needs 3 bind variables,
`:a1`, `:a2` and `:a1` again. It is probably due to Oracle enhanced adapter
JDBC implementation handles bind variables by their order not their name
then we need to handle first `:a1` for `offset` and last `:a1` separately.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Oracle visitor gets undefined method `to_i' for #<Arel::Nodes::BindParam:0x00000002c92910>
3 participants