Permalink
Browse files

Use adapter add_limit_offset! method when building query.

  • Loading branch information...
1 parent e7fb6a9 commit 99694fdb00878f06942deb5f8686d7e3d2fca62b @miloops miloops committed Mar 25, 2010
Showing with 5 additions and 19 deletions.
  1. +0 −14 lib/arel/engines/sql/compilers/ibm_db_compiler.rb
  2. +5 −5 lib/arel/engines/sql/relations/compiler.rb
View
14 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
View
10 lib/arel/engines/sql/relations/compiler.rb
@@ -8,17 +8,17 @@ def initialize(relation)
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

0 comments on commit 99694fd

Please sign in to comment.