-
Notifications
You must be signed in to change notification settings - Fork 0
Development Environment on Windows
I tried to test the new adapterfor Rails3 on Windows and thought it would be a good idea to document my steps.
I didn’t know where to put my documentation, so I created a new entry here in the wiki.
( please tell me if I should put these information elsewhere .. maybe I should create an Issue ?)
-———————————
- Testing sqlserver-adapter 3.0.0.beta1
with ruby-odbc-099992pre3
with rails v3.0.0.beta4
on Windows XP on SQL Server 2005 (German)
24.06.2010
>>ruby -v
ruby 1.9.1p378 (2010-01-10 revision 26273) [i386-mingw32]
>> cd \
>> mkdir \RailsTest
>> cd \RailsTest
>> rails rails3test
>> git clone git://github.com/rails/rails.git rails3test/vendor/rails
>> git clone git://github.com/rails-sqlserver/2000-2005-adapter.git rails3/vendor/plugins/adapters/sqlserver
>> git clone git://github.com/rails-sqlserver/arel.git rails3test/vendor/arel
>> cd rails3test
>> cd arel
>> git checkout origin/sqlserver
>> cd vendor\plugings\adapters\sqlserver
>> git branch adapter_test_on_windows
>> git checkout adapter_test_on_windows
>> set RAILS_SOURCE=../../../rails # see sqlserver_helper.rb
>> set AREL_SOURCE=../../../arel
>> gem install bundler
>> gem install shoulda —version 2.10.3
>> gem install tzinfo
>> gem install i18n
…
>> [ Insert gem ‘ruby-odbc’ in gemfile ]
>> rake test
C:/RailsTest/rails3test/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:211:in `rescue in log’: ODBC::Er
ror: 37000 (2750) [Microsoft][SQL Native Client][SQL Server]Spalte oder Parameter Nr. 8: Die angegebene Spaltengenauigkeit 55 ist gr÷▀er als die maximale Genauigkeit 38.: CREATE TABLE [numeric_data] ([id] int NOT NULL IDENTITY PRIMARY KEY, [bank_balance] decimal(10,2), [big_bank_balance] decimal(15,2), [world_population] decimal(10,0), [my_house_population] decimal(2,0), [decimal_number_with_default] decimal(3,2) DEFAULT 2.78, [temperature] float(8), [atoms_in_universe] decimal(55,0)) (ActiveRecord::StatementInvalid)
decimal only allows 38 digits on SQL Server 2005
changed in
C:\RailsTest\rails3test\vendor\rails\activerecord\test\schema\schema.rb
diff --git a/activerecord/test/schema/schema.rb b/activerecord/test/schema/schema.rb
index b212e7c..5f87898 100644
--- a/activerecord/test/schema/schema.rb
+++ b/activerecord/test/schema/schema.rb
@@ -313,8 +313,8 @@ ActiveRecord::Schema.define do
t.decimal :my_house_population, :precision => 2, :scale => 0
t.decimal :decimal_number_with_default, :precision => 3, :scale => 2, :default => 2.78
t.float :temperature
- # Oracle supports precision up to 38
- if current_adapter?(:OracleAdapter)
+ # Oracle and Microsoft supports precision up to 38
+ if current_adapter?(:OracleAdapter) || current_adapter?(:SQLServerAdapter)
t.decimal :atoms_in_universe, :precision => 38, :scale => 0
else
t.decimal :atoms_in_universe, :precision => 55, :scale => 025.06.2010
rake test
1) Error:test: For DatabaseStatements altering isolation levels should barf if the requested isolation level is not valid. (AdapterTestSqlserver):
ActiveRecord::StatementInvalid: ODBC::Error: 22008 (242) [Microsoft][SQL Native Client][SQL Server]Bei der Konvertierung eines char-Datentyps in einen datetime-Datentyp liegt der datetime-Wert außerhalb des gültigen Bereichs.: INSERT INTO [tasks] ([id], [starting], [ending]) VALUES (1, ‘2005-03-30 07:30:00.000’, ‘2005-03-30 09:30:00.000’)
..
C:/RailsTest/rails3test/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:239:in `insert_fixture’
…
169 tests, 231 assertions, 1 failures, 95 errors, 0 skips
rake aborted!
and most of them failing due to the DateTime Format !!!!
modified quoted_date :
def quoted_date(value)@
if value.acts_like?(:time)@
if value.respond_to?(:usec) && value.usec != 0
if sqlserver_2008?
value.iso8601(6)
else
value.utc.iso8601(6)
end
else
if sqlserver_2008?
value.iso8601
else
value.utc.iso8601
end
end
else
super
end
endNow down to 27 errors:
169 tests, 370 assertions, 2 failures, 27 errors, 0 skips
rake aborted!
The first error is in test: For chronic data types with a usec finding existing DB objects should find 003 millisecond in the DB with before and after casting. (AdapterTestSqlserver):
bc. ActiveRecord::StatementInvalid: ODBC::Error: 22008 (242) [Microsoft][SQL Native Client][SQL Server]Bei der Konvertierung eines char-Datentyps in einen datetime-Datentyp liegt der datetime-Wert außerhalb des gültigen Bereichs.: DELETE FROM [sql_server_chronics] WHERE [datetime] = ‘2012-12-31 10:24:36.003’
setup do
@time = Time.now
@db_datetime_003 = '2012-12-31 10:24:36.003'
@db_datetime_123 = '2012-12-31 10:24:36.123'
@all_datetimes = [@db_datetime_003, @db_datetime_123]
@all_datetimes.each do |datetime|
@connection.execute("INSERT INTO [sql_server_chronics] ([datetime]) VALUES('#{datetime}')")
end
endThis test tries to insert dates in the american dateformat in my database running on german language… Fail ;-)
When I change @db_datetime_003 to an ISO8601 format ‘2012-12-31T10:24:36.003’
the test fails too:
bc. test: For chronic data types with a usec finding existing DB objects should find 003 millisecond in the DB with before and after casting. (AdapterTestSqlserver) [C:/RailsTest/rails3test/vendor/plugins/adapters/sqlserver/test/cases/adapter_test_sqlserver.rb:225]:
<“2012-12-31T10:24:36.003”> expected but was
<“2012-12-31 10:24:36.003”>.
the test:
bc. assert_equal @db_datetime_003, existing_003.datetime_before_type_cast
so the test is comparing to a string and assumes that datetime_before_type_cast is also a string ?!?!