From f852b608d140addcbdc7ecb85d42eef0bbd512c5 Mon Sep 17 00:00:00 2001 From: Yasuo Honda Date: Mon, 2 May 2016 13:31:06 +0000 Subject: 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. --- lib/arel/visitors/oracle12.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'lib') 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 -- cgit v1.2.3