diff options
author | Sean Griffin <sean@seantheprogrammer.com> | 2016-05-04 11:24:09 -0500 |
---|---|---|
committer | Sean Griffin <sean@seantheprogrammer.com> | 2016-05-04 11:24:09 -0500 |
commit | cd81da63fe2d8f2ada4becce7c582fbd9acba107 (patch) | |
tree | 3ccf4d3fdc2668b587708c26dda7390ab4bbe12d | |
parent | f2ad22320d82021277ab835d4d44bef5e8b61866 (diff) | |
parent | f852b608d140addcbdc7ecb85d42eef0bbd512c5 (diff) | |
download | rails-cd81da63fe2d8f2ada4becce7c582fbd9acba107.tar.gz rails-cd81da63fe2d8f2ada4becce7c582fbd9acba107.tar.bz2 rails-cd81da63fe2d8f2ada4becce7c582fbd9acba107.zip |
Merge pull request #430 from yahonda/oracle12_limit_and_lock_2
Raise ArgumentError if limit and lock are used for Oracle12 visitor
-rw-r--r-- | lib/arel/visitors/oracle12.rb | 8 | ||||
-rw-r--r-- | test/visitors/test_oracle12.rb | 7 |
2 files changed, 9 insertions, 6 deletions
diff --git a/lib/arel/visitors/oracle12.rb b/lib/arel/visitors/oracle12.rb index 4a42343c9b..d21a829848 100644 --- a/lib/arel/visitors/oracle12.rb +++ b/lib/arel/visitors/oracle12.rb @@ -6,10 +6,12 @@ module Arel def visit_Arel_Nodes_SelectStatement o, collector # Oracle does not allow LIMIT clause with select for update if o.limit && o.lock - o = o.dup - o.limit = [] + raise ArgumentError, <<-MSG + 'Combination of limit and lock is not supported. + because generated SQL statements + `SELECT FOR UPDATE and FETCH FIRST n ROWS` generates ORA-02014.` + MSG end - super end diff --git a/test/visitors/test_oracle12.rb b/test/visitors/test_oracle12.rb index df0f01b30b..3263007ddb 100644 --- a/test/visitors/test_oracle12.rb +++ b/test/visitors/test_oracle12.rb @@ -29,12 +29,13 @@ module Arel end describe 'locking' do - it 'removes limit when locking' do + it 'generates ArgumentError if limit and lock are used' do stmt = Nodes::SelectStatement.new stmt.limit = Nodes::Limit.new(10) stmt.lock = Nodes::Lock.new(Arel.sql('FOR UPDATE')) - sql = compile(stmt) - sql.must_be_like "SELECT FOR UPDATE" + assert_raises ArgumentError do + sql = compile(stmt) + end end it 'defaults to FOR UPDATE when locking' do |