diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-07-17 09:52:00 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-07-17 09:52:00 +0000 |
commit | 9870396ed13b720980957e848e4ce65582fd0d0b (patch) | |
tree | 7bbf760cea6582dc8199bd299917e07c98e7e5bb /activerecord/lib/active_record/connection_adapters | |
parent | bb62568cc36399ba1b6f5d6e9db9f7a71072ad1b (diff) | |
download | rails-9870396ed13b720980957e848e4ce65582fd0d0b.tar.gz rails-9870396ed13b720980957e848e4ce65582fd0d0b.tar.bz2 rails-9870396ed13b720980957e848e4ce65582fd0d0b.zip |
Fixed incompatibility in DB2 adapter with the new limit/offset approach #1718 [Maik Schmidt]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1850 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters')
-rwxr-xr-x | activerecord/lib/active_record/connection_adapters/abstract_adapter.rb | 2 | ||||
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/db2_adapter.rb | 13 |
2 files changed, 7 insertions, 8 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb index 163925df42..6eda3c0624 100755 --- a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb @@ -323,6 +323,8 @@ module ActiveRecord when String if column && column.type == :binary "'#{quote_string(column.string_to_binary(value))}'" # ' (for ruby-mode) + elsif column && [:integer, :float].include?(column.type) + value.to_s else "'#{quote_string(value)}'" # ' (for ruby-mode) end diff --git a/activerecord/lib/active_record/connection_adapters/db2_adapter.rb b/activerecord/lib/active_record/connection_adapters/db2_adapter.rb index 232764e37c..a80a227a6d 100644 --- a/activerecord/lib/active_record/connection_adapters/db2_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/db2_adapter.rb @@ -28,7 +28,7 @@ begin end module ConnectionAdapters - # The DB2 adapter works with the C-based CLI driver (http://raa.ruby-lang.org/project/ruby-db2/). + # The DB2 adapter works with the C-based CLI driver (http://rubyforge.org/projects/ruby-dbi/) # # Options: # @@ -91,12 +91,9 @@ begin string.gsub(/'/, "''") # ' (for ruby-mode) 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) - sql << " FETCH FIRST #{limit} ROWS ONLY" + def add_limit_offset!(sql, options) + sql << " FETCH FIRST #{options[:limit]} ROWS ONLY" if options[:limit] and !options[:limit].nil? + raise ArgumentError, 'add_limit_offset! not implemented.' if options[:offset] and !options[:offset].nil? end def columns(table_name, name = nil) @@ -128,7 +125,7 @@ begin stmt = nil log(sql, name) do stmt = DB2::Statement.new(@connection) - stmt.exec_direct("#{sql} with ur") + stmt.exec_direct("#{sql.gsub(/=\s*null/i, 'IS NULL')} with ur") end rows = [] |