aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2010-11-11 10:42:52 -0600
committerAaron Patterson <aaron.patterson@gmail.com>2010-11-11 10:42:52 -0600
commita0c206b356315380493881aa139a85928b9b88ae (patch)
treed4609cfc825d7e5ea5f07efda67b111d213996bd /lib
parentdbd0140974ed768705f3680d5d6e47a56305b965 (diff)
parent64b8765c22222821911f0018e30b03f80112a1f1 (diff)
downloadrails-a0c206b356315380493881aa139a85928b9b88ae.tar.gz
rails-a0c206b356315380493881aa139a85928b9b88ae.tar.bz2
rails-a0c206b356315380493881aa139a85928b9b88ae.zip
Merge branch 'master' of github.com:brynary/arel
* 'master' of github.com:brynary/arel: fix order_hacks method for Oracle when complex functions are used in order by
Diffstat (limited to 'lib')
-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 <<