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:
parent
e7fb6a9f92
commit
99694fdb00
2 changed files with 5 additions and 19 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue