diff options
author | Emilio Tagua <miloops@gmail.com> | 2010-03-25 12:09:19 -0300 |
---|---|---|
committer | Emilio Tagua <miloops@gmail.com> | 2010-03-25 13:20:32 -0300 |
commit | 99694fdb00878f06942deb5f8686d7e3d2fca62b (patch) | |
tree | 41aa12b3708479c4fed978711f3cae5643bf765c | |
parent | e7fb6a9f92fc9208a85735ecebc7fc4292498700 (diff) | |
download | rails-99694fdb00878f06942deb5f8686d7e3d2fca62b.tar.gz rails-99694fdb00878f06942deb5f8686d7e3d2fca62b.tar.bz2 rails-99694fdb00878f06942deb5f8686d7e3d2fca62b.zip |
Use adapter add_limit_offset! method when building query.
-rw-r--r-- | lib/arel/engines/sql/compilers/ibm_db_compiler.rb | 14 | ||||
-rw-r--r-- | lib/arel/engines/sql/relations/compiler.rb | 10 |
2 files changed, 5 insertions, 19 deletions
diff --git a/lib/arel/engines/sql/compilers/ibm_db_compiler.rb b/lib/arel/engines/sql/compilers/ibm_db_compiler.rb index e15e783160..8c5779a35e 100644 --- a/lib/arel/engines/sql/compilers/ibm_db_compiler.rb +++ b/lib/arel/engines/sql/compilers/ibm_db_compiler.rb @@ -31,20 +31,6 @@ module Arel module SqlCompiler class IBM_DBCompiler < GenericCompiler - def select_sql - query = build_query \ - "SELECT #{select_clauses.join(', ')}", - "FROM #{from_clauses}", - (joins(self) unless joins(self).blank? ), - ("WHERE #{where_clauses.join(" AND ")}" unless wheres.blank? ), - ("GROUP BY #{group_clauses.join(', ')}" unless groupings.blank? ), - ("HAVING #{having_clauses.join(', ')}" unless havings.blank? ), - ("ORDER BY #{order_clauses.join(', ')}" unless orders.blank? ) - engine.add_limit_offset!(query,{:limit=>taken,:offset=>skipped}) unless taken.blank? - query << "#{locked}" unless locked.blank? - query - end - def limited_update_conditions(conditions, taken) quoted_primary_key = engine.quote_table_name(primary_key) update_conditions = "WHERE #{quoted_primary_key} IN (SELECT #{quoted_primary_key} FROM #{engine.connection.quote_table_name table.name} #{conditions} " #Note: - ')' not added, limit segment is to be appended diff --git a/lib/arel/engines/sql/relations/compiler.rb b/lib/arel/engines/sql/relations/compiler.rb index fc8d484276..cc0deb7c88 100644 --- a/lib/arel/engines/sql/relations/compiler.rb +++ b/lib/arel/engines/sql/relations/compiler.rb @@ -8,17 +8,17 @@ module Arel end def select_sql - build_query \ + query = build_query \ "SELECT #{select_clauses.join(', ')}", "FROM #{from_clauses}", (joins(self) unless joins(self).blank? ), ("WHERE #{where_clauses.join(" AND ")}" unless wheres.blank? ), ("GROUP BY #{group_clauses.join(', ')}" unless groupings.blank? ), ("HAVING #{having_clauses.join(', ')}" unless havings.blank? ), - ("ORDER BY #{order_clauses.join(', ')}" unless orders.blank? ), - ("LIMIT #{taken}" unless taken.blank? ), - ("OFFSET #{skipped}" unless skipped.blank? ), - ("#{locked}" unless locked.blank?) + ("ORDER BY #{order_clauses.join(', ')}" unless orders.blank? ) + engine.add_limit_offset!(query,{ :limit => taken, :offset => skipped }) if taken || skipped + query << " #{locked}" unless locked.blank? + query end def delete_sql |