From d5e122002a806324f1613b3213b3038770e4328f Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Mon, 29 Jan 2007 22:06:08 +0000 Subject: 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 --- .../lib/active_record/connection_adapters/oracle_adapter.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'activerecord/lib/active_record') 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 -- cgit v1.2.3