Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/ext/tiny_tds/result.c b/ext/tiny_tds/result.c
- index 205677e..115db74 100644
- --- a/ext/tiny_tds/result.c
- +++ b/ext/tiny_tds/result.c
- @@ -74,7 +74,7 @@ static VALUE rb_tinytds_result_fetch_row(VALUE self, ID timezone, int symbolize_
- rwrap->fields = rb_ary_new2(rwrap->number_of_fields);
- for (i = 0; i < rwrap->number_of_fields; i++) {
- char *colname = dbcolname(rwrap->client, i+1);
- - VALUE field = symbolize_keys ? ID2SYM(rb_intern(colname)) : rb_obj_freeze(rb_str_new2(colname));
- + VALUE field = symbolize_keys ? ID2SYM(rb_intern(colname)) : rb_obj_freeze(ENCODED_STR_NEW2(colname));
- rb_ary_store(rwrap->fields, i, field);
- }
- }
- @@ -157,11 +157,15 @@ static VALUE rb_tinytds_result_fetch_row(VALUE self, ID timezone, int symbolize_
- val = ENCODED_STR_NEW2(converted_unique);
- break;
- }
- - case SYBDATETIME4:
- - dbconvert(rwrap->client, coltype, data, data_len, SYBDATETIME, data, data_len);
- + case SYBDATETIME4: {
- + DBDATETIME new_data;
- + dbconvert(rwrap->client, coltype, data, data_len, SYBDATETIME, &new_data, sizeof(new_data));
- + data = &new_data;
- + data_len = sizeof(new_data);
- + }
- case SYBDATETIME: {
- DBDATEREC date_rec;
- - dbdatecrack(rwrap->client, &date_rec, (DBDATETIME *)data);
- + dbdatecrack(rwrap->client, &date_rec, (DBDATETIME *)data);
- int year = date_rec.year,
- month = date_rec.month,
- day = date_rec.day,
- diff --git a/test/result_test.rb b/test/result_test.rb
- index a085caf..95ae0e8 100644
- --- a/test/result_test.rb
- +++ b/test/result_test.rb
- @@ -101,19 +101,21 @@ class ResultTest < TinyTds::TestCase
- end
- should 'delete, insert and find data' do
- - text = 'test insert and delete'
- + text = 'test insert and delete with umlaute öäüß'
- @client.execute("DELETE FROM [datatypes] WHERE [varchar_50] IS NOT NULL").do
- @client.execute("INSERT INTO [datatypes] ([varchar_50]) VALUES ('#{text}')").do
- - row = @client.execute("SELECT [varchar_50] FROM [datatypes] WHERE [varchar_50] IS NOT NULL").each.first
- + # row = @client.execute("SELECT [varchar_50] FROM [datatypes] WHERE [varchar_50] IS NOT NULL").each.first
- + row = @client.execute("SELECT [varchar_50] FROM [datatypes] WHERE [varchar_50] = '#{text}'").each.first
- assert row
- assert_equal text, row['varchar_50']
- end
- should 'insert and find unicode data' do
- - text = '✓'
- + text = "Unicode Smile: \u263A Theta: \u0398 Pts: \u20A7"
- @client.execute("DELETE FROM [datatypes] WHERE [nvarchar_50] IS NOT NULL").do
- @client.execute("INSERT INTO [datatypes] ([nvarchar_50]) VALUES (N'#{text}')").do
- - row = @client.execute("SELECT [nvarchar_50] FROM [datatypes] WHERE [nvarchar_50] IS NOT NULL").each.first
- + # row = @client.execute("SELECT [nvarchar_50] FROM [datatypes] WHERE [nvarchar_50] IS NOT NULL").each.first
- + row = @client.execute("SELECT [nvarchar_50] FROM [datatypes] WHERE [nvarchar_50] = N'#{text}'").each.first
- assert_equal text, row['nvarchar_50']
- end
- diff --git a/test/schema/sqlserver_2005.sql b/test/schema/sqlserver_2005.sql
- index 86626ad..57bd21c 100644
- --- a/test/schema/sqlserver_2005.sql
- +++ b/test/schema/sqlserver_2005.sql
- @@ -53,7 +53,8 @@ CREATE TABLE [datatypes] (
- [varbinary_max] [varbinary](max) NULL,
- [varchar_50] [varchar](50) NULL,
- [varchar_max] [varchar](max) NULL,
- - [xml] [xml] NULL
- + [xml] [xml] NULL,
- + [Special_öäüß_column] [varchar](50) NULL
- ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
- SET IDENTITY_INSERT [datatypes] ON
- @@ -106,9 +107,9 @@ INSERT INTO [datatypes] ([id], [numeric_18_0]) VALUES ( 192, 12345678901234
- INSERT INTO [datatypes] ([id], [numeric_36_2]) VALUES ( 193, 12345678901234567890.01 )
- INSERT INTO [datatypes] ([id], [numeric_36_2]) VALUES ( 194, 123.46 )
- INSERT INTO [datatypes] ([id], [nvarchar_50]) VALUES ( 201, N'test nvarchar_50' )
- -INSERT INTO [datatypes] ([id], [nvarchar_50]) VALUES ( 202, N'test nvarchar_50 åå' )
- +INSERT INTO [datatypes] ([id], [nvarchar_50]) VALUES ( 202, N'test nvarchar_50 öäüß' )
- INSERT INTO [datatypes] ([id], [nvarchar_max]) VALUES ( 211, N'test nvarchar_max' )
- -INSERT INTO [datatypes] ([id], [nvarchar_max]) VALUES ( 212, N'test nvarchar_max åå' )
- +INSERT INTO [datatypes] ([id], [nvarchar_max]) VALUES ( 212, N'test nvarchar_max öäüß' )
- INSERT INTO [datatypes] ([id], [real]) VALUES ( 221, 123.45 )
- INSERT INTO [datatypes] ([id], [real]) VALUES ( 222, 0.0 )
- INSERT INTO [datatypes] ([id], [real]) VALUES ( 223, 0.00001 )
- @@ -129,10 +130,10 @@ INSERT INTO [datatypes] ([id], [tinyint]) VALUES ( 302, 255 )
- INSERT INTO [datatypes] ([id], [uniqueidentifier]) VALUES ( 311, NEWID() )
- INSERT INTO [datatypes] ([id], [varbinary_50]) VALUES ( 321, 0x47494638396101000100910000fffffffffffffe010200000021f904041400ff002c00000000010001000002024401003b )
- INSERT INTO [datatypes] ([id], [varbinary_max]) VALUES ( 331, 0x47494638396101000100910000fffffffffffffe010200000021f904041400ff002c00000000010001000002024401003b )
- -INSERT INTO [datatypes] ([id], [varchar_50]) VALUES ( 341, 'test varchar_50' )
- -INSERT INTO [datatypes] ([id], [varchar_max]) VALUES ( 351, 'test varchar_max' )
- +INSERT INTO [datatypes] ([id], [varchar_50]) VALUES ( 341, 'test varchar_50 öäüß' )
- +INSERT INTO [datatypes] ([id], [varchar_max]) VALUES ( 351, 'test varchar_max öäüß' )
- INSERT INTO [datatypes] ([id], [xml]) VALUES ( 361, '<foo><bar>batz</bar></foo>' )
- -
- +INSERT INTO [datatypes] ([id], [Special_öäüß_column]) VALUES ( 370, "I'm still here!" )
- SET IDENTITY_INSERT [datatypes] OFF
- diff --git a/test/schema_test.rb b/test/schema_test.rb
- index a904c2e..a519e45 100644
- --- a/test/schema_test.rb
- +++ b/test/schema_test.rb
- @@ -128,7 +128,7 @@ class SchemaTest < TinyTds::TestCase
- should 'cast nvarchar' do
- assert_equal 'test nvarchar_50', find_value(201, :nvarchar_50)
- - assert_equal 'test nvarchar_50 åå', find_value(202, :nvarchar_50)
- + assert_equal 'test nvarchar_50 öäüß', find_value(202, :nvarchar_50)
- assert_utf8_encoding find_value(202, :nvarchar_50)
- end
- @@ -198,7 +198,7 @@ class SchemaTest < TinyTds::TestCase
- end
- should 'cast varchar' do
- - assert_equal 'test varchar_50', find_value(341, :varchar_50)
- + assert_equal 'test varchar_50 öäüß', find_value(341, :varchar_50)
- assert_utf8_encoding find_value(341, :varchar_50)
- end
- @@ -209,7 +209,7 @@ class SchemaTest < TinyTds::TestCase
- should 'cast nvarchar(max)' do
- assert_equal 'test nvarchar_max', find_value(211, :nvarchar_max)
- - assert_equal 'test nvarchar_max åå', find_value(212, :nvarchar_max)
- + assert_equal 'test nvarchar_max öäüß', find_value(212, :nvarchar_max)
- assert_utf8_encoding find_value(212, :nvarchar_max)
- end
- @@ -221,7 +221,7 @@ class SchemaTest < TinyTds::TestCase
- should 'cast varchar(max)' do
- value = find_value(351, :varchar_max)
- - assert_equal 'test varchar_max', value
- + assert_equal 'test varchar_max öäüß', value
- assert_utf8_encoding(value)
- end
- @@ -230,7 +230,13 @@ class SchemaTest < TinyTds::TestCase
- assert_equal '<foo><bar>batz</bar></foo>', value
- assert_utf8_encoding(value)
- end
- -
- +
- + should 'cast special column' do
- + value = find_value(370, :Special_öäüß_column)
- + assert_equal "I'm still here!", value
- + assert_utf8_encoding(value)
- + end
- +
- end if sqlserver_2005? || sqlserver_2008?
Add Comment
Please, Sign In to add comment