Permalink
Browse files

Added support for ODBC connections to MS SQL Server so you can connec…

…t from a non-Windows machine #1569 [Mark Imbriaco/DeLynn Berry] Added support for limit/offset with the MS SQL Server driver so that pagination will now work #1569 [DeLynn Berry]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1583 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 64612db commit f2a29ca43cb0de38a25bf7f68bca5c11871692ce @dhh dhh committed Jul 1, 2005
@@ -1,5 +1,9 @@
*SVN*
+* Added support for limit/offset with the MS SQL Server driver so that pagination will now work #1569 [DeLynn Berry]
+
+* Added support for ODBC connections to MS SQL Server so you can connect from a non-Windows machine #1569 [Mark Imbriaco/DeLynn Berry]
+
* Fixed that multiparameter posts ignored attr_protected #1532 [alec+rails@veryclever.net]
* Fixed problem with eager loading when using a has_and_belongs_to_many association using :association_foreign_key #1504 [flash@vanklinkenbergsoftware.nl]
@@ -38,7 +38,7 @@ Rake::TestTask.new("test_mysql_ruby") { |t|
t.verbose = true
}
-for adapter in %w( postgresql sqlite sqlite3 sqlserver db2 oci )
+for adapter in %w( postgresql sqlite sqlite3 sqlserver sqlserver_odbc db2 oci )
Rake::TestTask.new("test_#{adapter}") { |t|
t.libs << "test" << "test/connections/native_#{adapter}"
t.pattern = "test/*_test{,_#{adapter}}.rb"
@@ -748,11 +748,7 @@ def construct_finder_sql(options)
end
def add_limit!(sql, options)
- if options[:limit] && options[:offset]
- connection.add_limit_with_offset!(sql, options[:limit].to_i, options[:offset].to_i)
- elsif options[:limit]
- connection.add_limit_without_offset!(sql, options[:limit].to_i)
- end
+ connection.add_limit_offset!(sql, options)
end
# Adds a sanitized version of +conditions+ to the +sql+ string. Note that it's the passed +sql+ string is changed.
@@ -352,21 +352,15 @@ def adapter_name()
# Returns a string of the CREATE TABLE SQL statements for recreating the entire structure of the database.
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
+ def add_limit!(sql, options)
+ return unless options
+ add_limit_offset!(sql, options)
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}"
+ def add_limit_offset!(sql, options)
+ return if options[:limit].nil?
+ sql << " LIMIT #{options[:limit]}"
+ sql << " OFFSET #{options[:offset]}" if options.has_key?(:offset) and !options[:offset].nil?
end
def initialize_schema_information
@@ -172,11 +172,17 @@ def structure_dump
structure += select_one("SHOW CREATE TABLE #{table.to_a.first.last}")["Create Table"] + ";\n\n"
end
end
-
- def add_limit_with_offset!(sql, limit, offset)
- sql << " LIMIT #{offset}, #{limit}"
+
+ def add_limit_offset!(sql, options)
+ return if options[:limit].nil?
+
+ if options[:offset].blank?
+ sql << " LIMIT #{options[:limit]}"
+ else
+ sql << " LIMIT #{options[:offset]}, #{options[:limit]}"
+ end
end
-
+
def recreate_database(name)
drop_database(name)
create_database(name)
Oops, something went wrong.

0 comments on commit f2a29ca

Please sign in to comment.