1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Use adapter add_limit_offset! method when building query.

This commit is contained in:
Emilio Tagua 2010-03-25 12:09:19 -03:00
parent e7fb6a9f92
commit 99694fdb00
2 changed files with 5 additions and 19 deletions

View file

@ -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 file

@ -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