aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-03-20 21:56:50 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-03-20 21:56:50 +0000
commitee8d110068e958b400987b5f224e14e292fd0558 (patch)
treea94385c7b5cddb6704d2e6d53aa8097bd5363198 /activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
parent9fe45f31ebeb772fdd1bc850c12cd465463e2ef7 (diff)
downloadrails-ee8d110068e958b400987b5f224e14e292fd0558.tar.gz
rails-ee8d110068e958b400987b5f224e14e292fd0558.tar.bz2
rails-ee8d110068e958b400987b5f224e14e292fd0558.zip
Added adapter independent limit clause as a two-element array with the first being the limit, the second being the offset #795 [Sam Stephenson]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@944 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/abstract_adapter.rb')
-rwxr-xr-xactiverecord/lib/active_record/connection_adapters/abstract_adapter.rb14
1 files changed, 13 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
index 0ed496ea43..bc30a94c97 100755
--- a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
@@ -353,10 +353,22 @@ module ActiveRecord
def structure_dump() end
def add_limit!(sql, limit)
+ if limit.is_a? Array
+ limit, offset = *limit
+ add_limit_with_offset!(sql, limit.to_i, offset.to_i)
+ else
+ add_limit_without_offset!(sql, limit)
+ end
+ end
+
+ def add_limit_with_offset!(sql, limit, offset)
+ sql << " LIMIT #{limit} OFFSET #{offset}"
+ end
+
+ def add_limit_without_offset!(sql, limit)
sql << " LIMIT #{limit}"
end
-
def initialize_schema_information
begin
execute "CREATE TABLE schema_info (version #{native_database_types[:integer][:name]}#{native_database_types[:integer][:limit]})"