Skip to content
This repository
Browse code

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...
commit ee2397036fc8d4a9498617349fb391389d8bb933 1 parent 91dff30
Jeremy Kemper jeremy authored
2  activerecord/CHANGELOG
... ... @@ -1,5 +1,7 @@
1 1 *SVN*
2 2
  3 +* 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]
  4 +
3 5 * SQLServer: fix eager association test. #5901 [Tom Ward]
4 6
5 7 * Clashing type columns due to a sloppy join shouldn't wreck single-table inheritance. #5838 [Kevin Clark]
3  activerecord/lib/active_record/connection_adapters/sqlserver_adapter.rb
@@ -356,7 +356,8 @@ def quote(value, column = nil)
356 356 case value
357 357 when TrueClass then '1'
358 358 when FalseClass then '0'
359   - when Time, DateTime then "'#{value.strftime("%Y-%m-%d %H:%M:%S")}'"
  359 + when Time, DateTime then "'#{value.strftime("%Y%m%d %H:%M:%S")}'"
  360 + when Date then "'#{value.strftime("%Y%m%d")}'"
360 361 else super
361 362 end
362 363 end
18 activerecord/test/adapter_test_sqlserver.rb
@@ -5,11 +5,25 @@
5 5
6 6 class SqlServerAdapterTest < Test::Unit::TestCase
7 7 fixtures :posts, :tasks
8   -
  8 +
9 9 def setup
10 10 @connection = ActiveRecord::Base.connection
11 11 end
12   -
  12 +
  13 + def teardown
  14 + @connection.execute("SET LANGUAGE us_english")
  15 + end
  16 +
  17 + # SQL Server 2000 has a bug where some unambiguous date formats are not
  18 + # correctly identified if the session language is set to german
  19 + def test_date_insertion_when_language_is_german
  20 + @connection.execute("SET LANGUAGE deutsch")
  21 +
  22 + assert_nothing_raised do
  23 + Task.create(:starting => Time.utc(2000, 1, 31, 5, 42, 0), :ending => Date.new(2006, 12, 31))
  24 + end
  25 + end
  26 +
13 27 def test_execute_without_block_closes_statement
14 28 assert_all_statements_used_are_closed do
15 29 @connection.execute("SELECT 1")

0 comments on commit ee23970

Please sign in to comment.
Something went wrong with that request. Please try again.