diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2007-01-29 22:06:08 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2007-01-29 22:06:08 +0000 |
commit | d5e122002a806324f1613b3213b3038770e4328f (patch) | |
tree | 728c78168fec49915d7469c4f10db150232b3981 /activerecord/lib/active_record | |
parent | 6b5238aadeb778a7067f93376a6a57a8eeda8379 (diff) | |
download | rails-d5e122002a806324f1613b3213b3038770e4328f.tar.gz rails-d5e122002a806324f1613b3213b3038770e4328f.tar.bz2 rails-d5e122002a806324f1613b3213b3038770e4328f.zip |
Oracle: fix lob and text default handling. Closes #7344.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6090 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/oracle_adapter.rb | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/oracle_adapter.rb b/activerecord/lib/active_record/connection_adapters/oracle_adapter.rb index 4e7c3c395c..7e6ef121e2 100644 --- a/activerecord/lib/active_record/connection_adapters/oracle_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/oracle_adapter.rb @@ -170,7 +170,7 @@ begin end def quote(value, column = nil) #:nodoc: - if column && [:text, :binary].include?(column.type) + if value && column && [:text, :binary].include?(column.type) %Q{empty_#{ column.sql_type.downcase rescue 'blob' }()} else super @@ -338,7 +338,7 @@ begin if row['data_default'] row['data_default'].sub!(/^(.*?)\s*$/, '\1') row['data_default'].sub!(/^'(.*)'$/, '\1') - row['data_default'] = nil if row['data_default'] =~ /^null$/i + row['data_default'] = nil if row['data_default'] =~ /^(null|empty_[bc]lob\(\))$/i end OracleColumn.new(oracle_downcase(row['name']), @@ -447,6 +447,14 @@ begin end end + def add_column_options!(sql, options) #:nodoc: + # handle case of defaults for CLOB columns, which would otherwise get "quoted" incorrectly + if options_include_default?(options) && (column = options[:column]) && column.type == :text + sql << " DEFAULT #{quote(options.delete(:default))}" + end + super + end + # SELECT DISTINCT clause for a given set of columns and a given ORDER BY clause. # # Oracle requires the ORDER BY columns to be in the SELECT list for DISTINCT |