Permalink
Browse files

SQLServer: work around bug where some unambiguous date formats are no…

…t correctly identified if the session language is set to german. Closes #5894.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4816 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 91dff30 commit ee2397036fc8d4a9498617349fb391389d8bb933 @jeremy jeremy committed Aug 25, 2006
View
@@ -1,5 +1,7 @@
*SVN*
+* SQLServer: work around bug where some unambiguous date formats are not correctly identified if the session language is set to german. #5894 [Tom Ward, kruth@bfpi]
+
* SQLServer: fix eager association test. #5901 [Tom Ward]
* Clashing type columns due to a sloppy join shouldn't wreck single-table inheritance. #5838 [Kevin Clark]
@@ -356,7 +356,8 @@ def quote(value, column = nil)
case value
when TrueClass then '1'
when FalseClass then '0'
- when Time, DateTime then "'#{value.strftime("%Y-%m-%d %H:%M:%S")}'"
+ when Time, DateTime then "'#{value.strftime("%Y%m%d %H:%M:%S")}'"
+ when Date then "'#{value.strftime("%Y%m%d")}'"
else super
end
end
@@ -5,11 +5,25 @@
class SqlServerAdapterTest < Test::Unit::TestCase
fixtures :posts, :tasks
-
+
def setup
@connection = ActiveRecord::Base.connection
end
-
+
+ def teardown
+ @connection.execute("SET LANGUAGE us_english")
+ end
+
+ # SQL Server 2000 has a bug where some unambiguous date formats are not
+ # correctly identified if the session language is set to german
+ def test_date_insertion_when_language_is_german
+ @connection.execute("SET LANGUAGE deutsch")
+
+ assert_nothing_raised do
+ Task.create(:starting => Time.utc(2000, 1, 31, 5, 42, 0), :ending => Date.new(2006, 12, 31))
+ end
+ end
+
def test_execute_without_block_closes_statement
assert_all_statements_used_are_closed do
@connection.execute("SELECT 1")

0 comments on commit ee23970

Please sign in to comment.