aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2007-01-28 17:51:21 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2007-01-28 17:51:21 +0000
commit16f6bd4070d57fc1eacb1a531385af205233a573 (patch)
treeea3781be6bcaa09ab34ba442e34f741b09ac34b4 /activerecord
parente720ba0b5f40ca1714a9c59b74da8ab0a0d3e00e (diff)
downloadrails-16f6bd4070d57fc1eacb1a531385af205233a573.tar.gz
rails-16f6bd4070d57fc1eacb1a531385af205233a573.tar.bz2
rails-16f6bd4070d57fc1eacb1a531385af205233a573.zip
SQLServer: don't choke on strings containing 'null'. Closes #7083.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6084 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/CHANGELOG2
-rw-r--r--activerecord/lib/active_record/connection_adapters/sqlserver_adapter.rb2
-rwxr-xr-xactiverecord/test/base_test.rb12
3 files changed, 13 insertions, 3 deletions
diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG
index 100333c88c..6246e5a4c2 100644
--- a/activerecord/CHANGELOG
+++ b/activerecord/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* SQLServer: don't choke on strings containing 'null'. #7083 [Jakob S]
+
* MySQL: blob and text columns may not have defaults in 5.x. Update fixtures schema for strict mode. #6695 [Dan Kubb]
* update_all can take a Hash argument. sanitize_sql splits into two methods for conditions and assignment since NULL values and delimiters are handled differently. #6583, #7365 [sandofsky, Assaf]
diff --git a/activerecord/lib/active_record/connection_adapters/sqlserver_adapter.rb b/activerecord/lib/active_record/connection_adapters/sqlserver_adapter.rb
index 92ac249fdf..e85a826942 100644
--- a/activerecord/lib/active_record/connection_adapters/sqlserver_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/sqlserver_adapter.rb
@@ -73,7 +73,7 @@ module ActiveRecord
end
def type_cast(value)
- return nil if value.nil? || value =~ /^\s*null\s*$/i
+ return nil if value.nil?
case type
when :datetime then cast_to_datetime(value)
when :timestamp then cast_to_time(value)
diff --git a/activerecord/test/base_test.rb b/activerecord/test/base_test.rb
index 8892dcbdc8..f2991bc721 100755
--- a/activerecord/test/base_test.rb
+++ b/activerecord/test/base_test.rb
@@ -164,8 +164,16 @@ class BasicsTest < Test::Unit::TestCase
topic.reload
assert_equal("null", topic.title)
assert_equal("null", topic.author_name)
- end
-
+ end
+
+ def test_save_nil_string_attributes
+ topic = Topic.find(1)
+ topic.title = nil
+ topic.save!
+ topic.reload
+ assert_nil topic.title
+ end
+
def test_hashes_not_mangled
new_topic = { :title => "New Topic" }
new_topic_values = { :title => "AnotherTopic" }