diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-09-06 18:56:16 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-09-06 18:56:16 -0700 |
commit | b541a963bd94e189219619553476321f4be37490 (patch) | |
tree | 88695bdd8b617441ed5bb98172a4faf17c0c24a8 /activerecord/lib/active_record | |
parent | 32157a2dd208f7417ba09c645be6cd28a1dca988 (diff) | |
download | rails-b541a963bd94e189219619553476321f4be37490.tar.gz rails-b541a963bd94e189219619553476321f4be37490.tar.bz2 rails-b541a963bd94e189219619553476321f4be37490.zip |
cleaning up confusing logic
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/relation/query_methods.rb | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb index 6005105cc9..f410492b0a 100644 --- a/activerecord/lib/active_record/relation/query_methods.rb +++ b/activerecord/lib/active_record/relation/query_methods.rb @@ -274,10 +274,13 @@ module ActiveRecord @implicit_readonly = false # TODO: fix this ugly hack, we should refactor the callers to get an ARel compatible array. # Before this change we were passing to ARel the last element only, and ARel is capable of handling an array - if selects.all? {|s| s.is_a?(String) || !s.is_a?(Arel::Expression) } && !(selects.last =~ /^COUNT\(/) - arel.project(*selects) + case select = selects.last + when Arel::Expression, Arel::SqlLiteral + arel.project(select) + when /^COUNT\(/ + arel.project(Arel::SqlLiteral.new(select)) else - arel.project(selects.last) + arel.project(*selects) end else arel.project(Arel::SqlLiteral.new(@klass.quoted_table_name + '.*')) |