diff options
author | Yasuo Honda <yasuo.honda@gmail.com> | 2016-05-02 13:31:06 +0000 |
---|---|---|
committer | Yasuo Honda <yasuo.honda@gmail.com> | 2016-05-02 14:22:15 +0000 |
commit | f852b608d140addcbdc7ecb85d42eef0bbd512c5 (patch) | |
tree | 3ccf4d3fdc2668b587708c26dda7390ab4bbe12d /lib/arel/visitors | |
parent | f2ad22320d82021277ab835d4d44bef5e8b61866 (diff) | |
download | rails-f852b608d140addcbdc7ecb85d42eef0bbd512c5.tar.gz rails-f852b608d140addcbdc7ecb85d42eef0bbd512c5.tar.bz2 rails-f852b608d140addcbdc7ecb85d42eef0bbd512c5.zip |
Raise ArgumentError if limit and lock are used for Oracle12 visitor
it would generates `SELECT ... FETCH FIRST n ROWS ONLY FOR UPDATE`
which causes Oracle 12c database returns this error :
ORA-02014: cannot select FOR UPDATE from view with DISTINCT, GROUP BY, etc.
Diffstat (limited to 'lib/arel/visitors')
-rw-r--r-- | lib/arel/visitors/oracle12.rb | 8 |
1 files changed, 5 insertions, 3 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 |