aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/sqlserver_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/sqlserver_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/sqlserver_adapter.rb')
-rw-r--r--activerecord/lib/active_record/connection_adapters/sqlserver_adapter.rb19
1 files changed, 6 insertions, 13 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/sqlserver_adapter.rb b/activerecord/lib/active_record/connection_adapters/sqlserver_adapter.rb
index f6325d845c..adc7e9d98f 100644
--- a/activerecord/lib/active_record/connection_adapters/sqlserver_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/sqlserver_adapter.rb
@@ -253,19 +253,12 @@ EOL
"[#{name}]"
end
- def add_limit!(sql, limit)
- if sql =~ /LIMIT/i
- limit = sql.slice!(/LIMIT.*/).gsub(/LIMIT.(.*)$/, '\1')
- end
- if !limit.nil?
- limit_amount = limit.to_s.include?("OFFSET") ? get_offset_amount(limit) : Array.new([limit])
- order_by = sql.include?("ORDER BY") ? get_order_by(sql.sub(/.*ORDER\sBY./, "")) : nil
- if limit_amount.size == 2
- sql.gsub!(/SELECT/i, "SELECT * FROM ( SELECT TOP #{limit_amount[0]} * FROM ( SELECT TOP #{limit_amount[1]}")<<" ) AS tmp1 ORDER BY #{order_by[1]} ) AS tmp2 ORDER BY #{order_by[0]}"
- else
- sql.gsub!(/SELECT/i, "SELECT TOP #{limit_amount[0]}")
- end
- end
+ def add_limit_with_offset!(sql, limit, offset)
+ raise ArgumentError, 'add_limit_with_offset! not implemented'
+ end
+
+ def add_limit_without_offset!(sql, limit)
+ raise ArgumentError, 'add_limit_without_offset! not implemented'
end
def recreate_database(name)