diff options
author | Raimonds Simanovskis <raimonds.simanovskis@gmail.com> | 2010-11-06 19:11:23 +0200 |
---|---|---|
committer | Raimonds Simanovskis <raimonds.simanovskis@gmail.com> | 2010-11-06 19:11:23 +0200 |
commit | 64b8765c22222821911f0018e30b03f80112a1f1 (patch) | |
tree | 866f9755a2cc8e4dbb25391a2e407bd16adf7158 | |
parent | d9d9944b37b959c6b6f00d4f38048cc541a56ad8 (diff) | |
download | rails-64b8765c22222821911f0018e30b03f80112a1f1.tar.gz rails-64b8765c22222821911f0018e30b03f80112a1f1.tar.bz2 rails-64b8765c22222821911f0018e30b03f80112a1f1.zip |
fix order_hacks method for Oracle when complex functions are used in order by
-rw-r--r-- | lib/arel/visitors/oracle.rb | 18 |
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 << |