aboutsummaryrefslogtreecommitdiffstats
path: root/lib/arel/visitors/oracle.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/arel/visitors/oracle.rb')
-rw-r--r--lib/arel/visitors/oracle.rb18
1 files changed, 17 insertions, 1 deletions
diff --git a/lib/arel/visitors/oracle.rb b/lib/arel/visitors/oracle.rb
index 212c18ada4..bb6ebd4ab8 100644
--- a/lib/arel/visitors/oracle.rb
+++ b/lib/arel/visitors/oracle.rb
@@ -70,7 +70,23 @@ module Arel
/DISTINCT.*FIRST_VALUE/ === projection
end
end
- orders = o.orders.map { |x| visit x }.join(', ').split(',')
+ # FIXME: previous version with join and split broke ORDER BY clause
+ # if it contained functions with several arguments (separated by ',').
+ # Currently splitting is done only if there is no function calls
+ #
+ # orders = o.orders.map { |x| visit x }.join(', ').split(',')
+ orders = o.orders.map do |x|
+ string = visit x
+ # if there is function call
+ if string.include?('(')
+ string
+ # if no function call then comma splits several ORDER BY columns
+ elsif string.include?(',')
+ string.split(',')
+ else
+ string
+ end
+ end.flatten
o.orders = []
orders.each_with_index do |order, i|
o.orders <<