From 71a4f7161fb02cd5b2cefb374224be94b185306a Mon Sep 17 00:00:00 2001 From: Michael Koziarski Date: Tue, 16 Jan 2007 01:39:05 +0000 Subject: Allow the Oracle adapter to insert a string "null". Closes #6997 [laurelfan] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5958 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- .../lib/active_record/connection_adapters/oracle_adapter.rb | 1 - activerecord/test/base_test.rb | 11 ++++++++++- 2 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 b44510fd7d..01eb350da4 100644 --- a/activerecord/lib/active_record/connection_adapters/oracle_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/oracle_adapter.rb @@ -66,7 +66,6 @@ begin class OracleColumn < Column #:nodoc: def type_cast(value) - return nil if value =~ /^\s*null\s*$/i return guess_date_or_time(value) if type == :datetime && OracleAdapter.emulate_dates super end diff --git a/activerecord/test/base_test.rb b/activerecord/test/base_test.rb index 672ad6f0bc..e1dd5704db 100755 --- a/activerecord/test/base_test.rb +++ b/activerecord/test/base_test.rb @@ -69,7 +69,7 @@ class BasicsTest < Test::Unit::TestCase assert_equal("Jason", topic.author_name) assert_equal(topics(:first).author_email_address, Topic.find(1).author_email_address) end - + def test_integers_as_nil test = AutoId.create('value' => '') assert_nil AutoId.find(test.id).value @@ -156,6 +156,15 @@ class BasicsTest < Test::Unit::TestCase reply = Reply.new assert_raise(ActiveRecord::RecordInvalid) { reply.save! } end + + def test_save_null_string_attributes + topic = Topic.find(1) + topic.attributes = { "title" => "null", "author_name" => "null" } + topic.save! + topic.reload + assert_equal("null", topic.title) + assert_equal("null", topic.author_name) + end def test_hashes_not_mangled new_topic = { :title => "New Topic" } -- cgit v1.2.3