tiny_tds 0.7.0-x86-mingw32 → 0.9.5.beta.1-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,16 +1,16 @@
1
1
 
2
2
  /*
3
3
 
4
- * Binary Data - Our test binary data is a 1 pixel gif. The basic (raw) data is below. Quoting this data
5
- would involve this (encode) method and be (encoded) with the 0x prefix for raw SQL. In other clients the
4
+ * Binary Data - Our test binary data is a 1 pixel gif. The basic (raw) data is below. Quoting this data
5
+ would involve this (encode) method and be (encoded) with the 0x prefix for raw SQL. In other clients the
6
6
  (raw_db) value without the 0x prefix would need to be (packed) again yield the original (raw) value.
7
-
7
+
8
8
  (raw) - "GIF89a\001\000\001\000\221\000\000\377\377\377\377\377\377\376\001\002\000\000\000!\371\004\004\024\000\377\000,\000\000\000\000\001\000\001\000\000\002\002D\001\000;"
9
9
  (encode) - "0x#{raw.unpack("H*")[0]}"
10
10
  (encoded) - "0x47494638396101000100910000fffffffffffffe010200000021f904041400ff002c00000000010001000002024401003b"
11
11
  (raw_db) - "47494638396101000100910000fffffffffffffe010200000021f904041400ff002c00000000010001000002024401003b"
12
12
  (packed) - [raw_db].pack('H*')
13
-
13
+
14
14
  */
15
15
 
16
16
  CREATE TABLE [dbo].[datatypes] (
@@ -70,13 +70,13 @@ INSERT INTO [datatypes] ([id], [char_10]) VALUES ( 42, '12345678' )
70
70
  INSERT INTO [datatypes] ([id], [datetime]) VALUES ( 61, '1753-01-01T00:00:00.000' )
71
71
  INSERT INTO [datatypes] ([id], [datetime]) VALUES ( 62, '9999-12-31T23:59:59.997' )
72
72
  INSERT INTO [datatypes] ([id], [datetime]) VALUES ( 63, '2010-01-01T12:34:56.123' )
73
- -- INSERT INTO [datatypes] ([id], [datetime2_7]) VALUES ( 71, '0001-01-01T00:00:00.0000000Z' )
74
- -- INSERT INTO [datatypes] ([id], [datetime2_7]) VALUES ( 72, '1984-01-24T04:20:00.0000000-08:00' )
75
- -- INSERT INTO [datatypes] ([id], [datetime2_7]) VALUES ( 73, '9999-12-31T23:59:59.9999999Z' )
76
- -- INSERT INTO [datatypes] ([id], [datetimeoffset_2]) VALUES ( 81, '1984-01-24T04:20:00.0000000-08:00' ) -- 1984-01-24 04:20:00.00 -08:00
73
+ -- INSERT INTO [datatypes] ([id], [datetime2_7]) VALUES ( 71, '0001-01-01 00:00:00.0000000' )
74
+ -- INSERT INTO [datatypes] ([id], [datetime2_7]) VALUES ( 72, '1984-01-24 04:20:00.0000000' )
75
+ -- INSERT INTO [datatypes] ([id], [datetime2_7]) VALUES ( 73, '9999-12-31 23:59:59.9999999' )
76
+ -- INSERT INTO [datatypes] ([id], [datetimeoffset_2]) VALUES ( 81, '1984-01-24T04:20:00.1234567-08:00' ) -- 1984-01-24 04:20:00.00 -08:00
77
77
  -- INSERT INTO [datatypes] ([id], [datetimeoffset_2]) VALUES ( 82, '1984-01-24T04:20:00.0000000Z' ) -- 1984-01-24 04:20:00.00 +00:00
78
78
  -- INSERT INTO [datatypes] ([id], [datetimeoffset_2]) VALUES ( 83, '9999-12-31T23:59:59.9999999Z' ) -- 9999-12-31 23:59:59.99 +00:00
79
- -- INSERT INTO [datatypes] ([id], [datetimeoffset_7]) VALUES ( 84, '1984-01-24T04:20:00.0000000-08:00' ) -- 1984-01-24 04:20:00.0000000 -08:00
79
+ -- INSERT INTO [datatypes] ([id], [datetimeoffset_7]) VALUES ( 84, '1984-01-24T04:20:00.1234567-08:00' ) -- 1984-01-24 04:20:00.1234567 -08:00
80
80
  -- INSERT INTO [datatypes] ([id], [datetimeoffset_7]) VALUES ( 85, '1984-01-24T04:20:00.0000000Z' ) -- 1984-01-24 04:20:00.0000000 +00:00
81
81
  -- INSERT INTO [datatypes] ([id], [datetimeoffset_7]) VALUES ( 86, '9999-12-31T23:59:59.9999999Z' ) -- 9999-12-31 23:59:59.9999999 +00:00
82
82
  INSERT INTO [datatypes] ([id], [decimal_9_2]) VALUES ( 91, 12345.01 )
@@ -120,10 +120,10 @@ INSERT INTO [datatypes] ([id], [smallmoney]) VALUES ( 251, 4.20 )
120
120
  INSERT INTO [datatypes] ([id], [smallmoney]) VALUES ( 252, -214748.3647 )
121
121
  INSERT INTO [datatypes] ([id], [smallmoney]) VALUES ( 253, 214748.3646 )
122
122
  INSERT INTO [datatypes] ([id], [text]) VALUES ( 271, 'test text' )
123
- -- INSERT INTO [datatypes] ([id], [time_2]) VALUES ( 281, '1901-01-01T15:45:00.0100001Z' ) -- 15:45:00.01
124
- -- INSERT INTO [datatypes] ([id], [time_2]) VALUES ( 282, '1984-01-24T04:20:00.0000001-08:00' ) -- 04:20:00.00
125
- -- INSERT INTO [datatypes] ([id], [time_7]) VALUES ( 283, '1901-01-01T15:45:00.0100001Z' ) -- 15:45:00.0100001
126
- -- INSERT INTO [datatypes] ([id], [time_7]) VALUES ( 284, '1984-01-24T04:20:00.0000001-08:00' ) -- 04:20:00.0000001
123
+ -- INSERT INTO [datatypes] ([id], [time_2]) VALUES ( 281, '15:45:00.709714966' ) -- 15:45:00.71
124
+ -- INSERT INTO [datatypes] ([id], [time_2]) VALUES ( 282, '04:20:00.288321545' ) -- 04:20:00.29
125
+ -- INSERT INTO [datatypes] ([id], [time_7]) VALUES ( 283, '15:45:00.709714966' ) -- 15:45:00.709714900
126
+ -- INSERT INTO [datatypes] ([id], [time_7]) VALUES ( 284, '04:20:00.288321545' ) -- 04:20:00.288321500
127
127
  INSERT INTO [datatypes] ([id], [tinyint]) VALUES ( 301, 0 )
128
128
  INSERT INTO [datatypes] ([id], [tinyint]) VALUES ( 302, 255 )
129
129
  INSERT INTO [datatypes] ([id], [uniqueidentifier]) VALUES ( 311, NEWID() )
@@ -1,16 +1,16 @@
1
1
 
2
2
  /*
3
3
 
4
- * Binary Data - Our test binary data is a 1 pixel gif. The basic (raw) data is below. Quoting this data
5
- would involve this (encode) method and be (encoded) with the 0x prefix for raw SQL. In other clients the
4
+ * Binary Data - Our test binary data is a 1 pixel gif. The basic (raw) data is below. Quoting this data
5
+ would involve this (encode) method and be (encoded) with the 0x prefix for raw SQL. In other clients the
6
6
  (raw_db) value without the 0x prefix would need to be (packed) again yield the original (raw) value.
7
-
7
+
8
8
  (raw) - "GIF89a\001\000\001\000\221\000\000\377\377\377\377\377\377\376\001\002\000\000\000!\371\004\004\024\000\377\000,\000\000\000\000\001\000\001\000\000\002\002D\001\000;"
9
9
  (encode) - "0x#{raw.unpack("H*")[0]}"
10
10
  (encoded) - "0x47494638396101000100910000fffffffffffffe010200000021f904041400ff002c00000000010001000002024401003b"
11
11
  (raw_db) - "47494638396101000100910000fffffffffffffe010200000021f904041400ff002c00000000010001000002024401003b"
12
12
  (packed) - [raw_db].pack('H*')
13
-
13
+
14
14
  */
15
15
 
16
16
  CREATE TABLE [dbo].[datatypes] (
@@ -70,13 +70,13 @@ INSERT INTO [datatypes] ([id], [char_10]) VALUES ( 42, '12345678' )
70
70
  INSERT INTO [datatypes] ([id], [datetime]) VALUES ( 61, '1753-01-01T00:00:00.000' )
71
71
  INSERT INTO [datatypes] ([id], [datetime]) VALUES ( 62, '9999-12-31T23:59:59.997' )
72
72
  INSERT INTO [datatypes] ([id], [datetime]) VALUES ( 63, '2010-01-01T12:34:56.123' )
73
- -- INSERT INTO [datatypes] ([id], [datetime2_7]) VALUES ( 71, '0001-01-01T00:00:00.0000000Z' )
74
- -- INSERT INTO [datatypes] ([id], [datetime2_7]) VALUES ( 72, '1984-01-24T04:20:00.0000000-08:00' )
75
- -- INSERT INTO [datatypes] ([id], [datetime2_7]) VALUES ( 73, '9999-12-31T23:59:59.9999999Z' )
76
- -- INSERT INTO [datatypes] ([id], [datetimeoffset_2]) VALUES ( 81, '1984-01-24T04:20:00.0000000-08:00' ) -- 1984-01-24 04:20:00.00 -08:00
73
+ -- INSERT INTO [datatypes] ([id], [datetime2_7]) VALUES ( 71, '0001-01-01 00:00:00.0000000' )
74
+ -- INSERT INTO [datatypes] ([id], [datetime2_7]) VALUES ( 72, '1984-01-24 04:20:00.0000000' )
75
+ -- INSERT INTO [datatypes] ([id], [datetime2_7]) VALUES ( 73, '9999-12-31 23:59:59.9999999' )
76
+ -- INSERT INTO [datatypes] ([id], [datetimeoffset_2]) VALUES ( 81, '1984-01-24T04:20:00.1234567-08:00' ) -- 1984-01-24 04:20:00.00 -08:00
77
77
  -- INSERT INTO [datatypes] ([id], [datetimeoffset_2]) VALUES ( 82, '1984-01-24T04:20:00.0000000Z' ) -- 1984-01-24 04:20:00.00 +00:00
78
78
  -- INSERT INTO [datatypes] ([id], [datetimeoffset_2]) VALUES ( 83, '9999-12-31T23:59:59.9999999Z' ) -- 9999-12-31 23:59:59.99 +00:00
79
- -- INSERT INTO [datatypes] ([id], [datetimeoffset_7]) VALUES ( 84, '1984-01-24T04:20:00.0000000-08:00' ) -- 1984-01-24 04:20:00.0000000 -08:00
79
+ -- INSERT INTO [datatypes] ([id], [datetimeoffset_7]) VALUES ( 84, '1984-01-24T04:20:00.1234567-08:00' ) -- 1984-01-24 04:20:00.1234567 -08:00
80
80
  -- INSERT INTO [datatypes] ([id], [datetimeoffset_7]) VALUES ( 85, '1984-01-24T04:20:00.0000000Z' ) -- 1984-01-24 04:20:00.0000000 +00:00
81
81
  -- INSERT INTO [datatypes] ([id], [datetimeoffset_7]) VALUES ( 86, '9999-12-31T23:59:59.9999999Z' ) -- 9999-12-31 23:59:59.9999999 +00:00
82
82
  INSERT INTO [datatypes] ([id], [decimal_9_2]) VALUES ( 91, 12345.01 )
@@ -120,10 +120,10 @@ INSERT INTO [datatypes] ([id], [smallmoney]) VALUES ( 251, 4.20 )
120
120
  INSERT INTO [datatypes] ([id], [smallmoney]) VALUES ( 252, -214748.3647 )
121
121
  INSERT INTO [datatypes] ([id], [smallmoney]) VALUES ( 253, 214748.3646 )
122
122
  INSERT INTO [datatypes] ([id], [text]) VALUES ( 271, 'test text' )
123
- -- INSERT INTO [datatypes] ([id], [time_2]) VALUES ( 281, '1901-01-01T15:45:00.0100001Z' ) -- 15:45:00.01
124
- -- INSERT INTO [datatypes] ([id], [time_2]) VALUES ( 282, '1984-01-24T04:20:00.0000001-08:00' ) -- 04:20:00.00
125
- -- INSERT INTO [datatypes] ([id], [time_7]) VALUES ( 283, '1901-01-01T15:45:00.0100001Z' ) -- 15:45:00.0100001
126
- -- INSERT INTO [datatypes] ([id], [time_7]) VALUES ( 284, '1984-01-24T04:20:00.0000001-08:00' ) -- 04:20:00.0000001
123
+ -- INSERT INTO [datatypes] ([id], [time_2]) VALUES ( 281, '15:45:00.709714966' ) -- 15:45:00.71
124
+ -- INSERT INTO [datatypes] ([id], [time_2]) VALUES ( 282, '04:20:00.288321545' ) -- 04:20:00.29
125
+ -- INSERT INTO [datatypes] ([id], [time_7]) VALUES ( 283, '15:45:00.709714966' ) -- 15:45:00.709714900
126
+ -- INSERT INTO [datatypes] ([id], [time_7]) VALUES ( 284, '04:20:00.288321545' ) -- 04:20:00.288321500
127
127
  INSERT INTO [datatypes] ([id], [tinyint]) VALUES ( 301, 0 )
128
128
  INSERT INTO [datatypes] ([id], [tinyint]) VALUES ( 302, 255 )
129
129
  INSERT INTO [datatypes] ([id], [uniqueidentifier]) VALUES ( 311, NEWID() )
@@ -1,16 +1,16 @@
1
1
 
2
2
  /*
3
3
 
4
- * Binary Data - Our test binary data is a 1 pixel gif. The basic (raw) data is below. Quoting this data
5
- would involve this (encode) method and be (encoded) with the 0x prefix for raw SQL. In other clients the
4
+ * Binary Data - Our test binary data is a 1 pixel gif. The basic (raw) data is below. Quoting this data
5
+ would involve this (encode) method and be (encoded) with the 0x prefix for raw SQL. In other clients the
6
6
  (raw_db) value without the 0x prefix would need to be (packed) again yield the original (raw) value.
7
-
7
+
8
8
  (raw) - "GIF89a\001\000\001\000\221\000\000\377\377\377\377\377\377\376\001\002\000\000\000!\371\004\004\024\000\377\000,\000\000\000\000\001\000\001\000\000\002\002D\001\000;"
9
9
  (encode) - "0x#{raw.unpack("H*")[0]}"
10
10
  (encoded) - "0x47494638396101000100910000fffffffffffffe010200000021f904041400ff002c00000000010001000002024401003b"
11
11
  (raw_db) - "47494638396101000100910000fffffffffffffe010200000021f904041400ff002c00000000010001000002024401003b"
12
12
  (packed) - [raw_db].pack('H*')
13
-
13
+
14
14
  */
15
15
 
16
16
  CREATE TABLE [dbo].[datatypes] (
@@ -70,13 +70,13 @@ INSERT INTO [datatypes] ([id], [date]) VALUES ( 52, '9999-12-31' )
70
70
  INSERT INTO [datatypes] ([id], [datetime]) VALUES ( 61, '1753-01-01T00:00:00.000' )
71
71
  INSERT INTO [datatypes] ([id], [datetime]) VALUES ( 62, '9999-12-31T23:59:59.997' )
72
72
  INSERT INTO [datatypes] ([id], [datetime]) VALUES ( 63, '2010-01-01T12:34:56.123' )
73
- INSERT INTO [datatypes] ([id], [datetime2_7]) VALUES ( 71, '0001-01-01T00:00:00.0000000Z' )
74
- INSERT INTO [datatypes] ([id], [datetime2_7]) VALUES ( 72, '1984-01-24T04:20:00.0000000-08:00' )
75
- INSERT INTO [datatypes] ([id], [datetime2_7]) VALUES ( 73, '9999-12-31T23:59:59.9999999Z' )
76
- INSERT INTO [datatypes] ([id], [datetimeoffset_2]) VALUES ( 81, '1984-01-24T04:20:00.0000000-08:00' ) -- 1984-01-24 04:20:00.00 -08:00
73
+ INSERT INTO [datatypes] ([id], [datetime2_7]) VALUES ( 71, '0001-01-01 00:00:00.0000000' )
74
+ INSERT INTO [datatypes] ([id], [datetime2_7]) VALUES ( 72, '1984-01-24 04:20:00.0000000' )
75
+ INSERT INTO [datatypes] ([id], [datetime2_7]) VALUES ( 73, '9999-12-31 23:59:59.9999999' )
76
+ INSERT INTO [datatypes] ([id], [datetimeoffset_2]) VALUES ( 81, '1984-01-24T04:20:00.1234567-08:00' ) -- 1984-01-24 04:20:00.00 -08:00
77
77
  INSERT INTO [datatypes] ([id], [datetimeoffset_2]) VALUES ( 82, '1984-01-24T04:20:00.0000000Z' ) -- 1984-01-24 04:20:00.00 +00:00
78
78
  INSERT INTO [datatypes] ([id], [datetimeoffset_2]) VALUES ( 83, '9999-12-31T23:59:59.9999999Z' ) -- 9999-12-31 23:59:59.99 +00:00
79
- INSERT INTO [datatypes] ([id], [datetimeoffset_7]) VALUES ( 84, '1984-01-24T04:20:00.0000000-08:00' ) -- 1984-01-24 04:20:00.0000000 -08:00
79
+ INSERT INTO [datatypes] ([id], [datetimeoffset_7]) VALUES ( 84, '1984-01-24T04:20:00.1234567-08:00' ) -- 1984-01-24 04:20:00.1234567 -08:00
80
80
  INSERT INTO [datatypes] ([id], [datetimeoffset_7]) VALUES ( 85, '1984-01-24T04:20:00.0000000Z' ) -- 1984-01-24 04:20:00.0000000 +00:00
81
81
  INSERT INTO [datatypes] ([id], [datetimeoffset_7]) VALUES ( 86, '9999-12-31T23:59:59.9999999Z' ) -- 9999-12-31 23:59:59.9999999 +00:00
82
82
  INSERT INTO [datatypes] ([id], [decimal_9_2]) VALUES ( 91, 12345.01 )
@@ -120,10 +120,10 @@ INSERT INTO [datatypes] ([id], [smallmoney]) VALUES ( 251, 4.20 )
120
120
  INSERT INTO [datatypes] ([id], [smallmoney]) VALUES ( 252, -214748.3647 )
121
121
  INSERT INTO [datatypes] ([id], [smallmoney]) VALUES ( 253, 214748.3646 )
122
122
  INSERT INTO [datatypes] ([id], [text]) VALUES ( 271, 'test text' )
123
- INSERT INTO [datatypes] ([id], [time_2]) VALUES ( 281, '1901-01-01T15:45:00.0100001Z' ) -- 15:45:00.01
124
- INSERT INTO [datatypes] ([id], [time_2]) VALUES ( 282, '1984-01-24T04:20:00.0000001-08:00' ) -- 04:20:00.00
125
- INSERT INTO [datatypes] ([id], [time_7]) VALUES ( 283, '1901-01-01T15:45:00.0100001Z' ) -- 15:45:00.0100001
126
- INSERT INTO [datatypes] ([id], [time_7]) VALUES ( 284, '1984-01-24T04:20:00.0000001-08:00' ) -- 04:20:00.0000001
123
+ INSERT INTO [datatypes] ([id], [time_2]) VALUES ( 281, '15:45:00.709714966' ) -- 15:45:00.71
124
+ INSERT INTO [datatypes] ([id], [time_2]) VALUES ( 282, '04:20:00.288321545' ) -- 04:20:00.29
125
+ INSERT INTO [datatypes] ([id], [time_7]) VALUES ( 283, '15:45:00.709714966' ) -- 15:45:00.709714900
126
+ INSERT INTO [datatypes] ([id], [time_7]) VALUES ( 284, '04:20:00.288321545' ) -- 04:20:00.288321500
127
127
  INSERT INTO [datatypes] ([id], [tinyint]) VALUES ( 301, 0 )
128
128
  INSERT INTO [datatypes] ([id], [tinyint]) VALUES ( 302, 255 )
129
129
  INSERT INTO [datatypes] ([id], [uniqueidentifier]) VALUES ( 311, NEWID() )
@@ -70,13 +70,13 @@ INSERT INTO [datatypes] ([id], [date]) VALUES ( 52, '9999-12-31' )
70
70
  INSERT INTO [datatypes] ([id], [datetime]) VALUES ( 61, '1753-01-01T00:00:00.000' )
71
71
  INSERT INTO [datatypes] ([id], [datetime]) VALUES ( 62, '9999-12-31T23:59:59.997' )
72
72
  INSERT INTO [datatypes] ([id], [datetime]) VALUES ( 63, '2010-01-01T12:34:56.123' )
73
- INSERT INTO [datatypes] ([id], [datetime2_7]) VALUES ( 71, '0001-01-01T00:00:00.0000000Z' )
74
- INSERT INTO [datatypes] ([id], [datetime2_7]) VALUES ( 72, '1984-01-24T04:20:00.0000000-08:00' )
75
- INSERT INTO [datatypes] ([id], [datetime2_7]) VALUES ( 73, '9999-12-31T23:59:59.9999999Z' )
76
- INSERT INTO [datatypes] ([id], [datetimeoffset_2]) VALUES ( 81, '1984-01-24T04:20:00.0000000-08:00' ) -- 1984-01-24 04:20:00.00 -08:00
73
+ INSERT INTO [datatypes] ([id], [datetime2_7]) VALUES ( 71, '0001-01-01 00:00:00.0000000' )
74
+ INSERT INTO [datatypes] ([id], [datetime2_7]) VALUES ( 72, '1984-01-24 04:20:00.0000000' )
75
+ INSERT INTO [datatypes] ([id], [datetime2_7]) VALUES ( 73, '9999-12-31 23:59:59.9999999' )
76
+ INSERT INTO [datatypes] ([id], [datetimeoffset_2]) VALUES ( 81, '1984-01-24T04:20:00.1234567-08:00' ) -- 1984-01-24 04:20:00.00 -08:00
77
77
  INSERT INTO [datatypes] ([id], [datetimeoffset_2]) VALUES ( 82, '1984-01-24T04:20:00.0000000Z' ) -- 1984-01-24 04:20:00.00 +00:00
78
78
  INSERT INTO [datatypes] ([id], [datetimeoffset_2]) VALUES ( 83, '9999-12-31T23:59:59.9999999Z' ) -- 9999-12-31 23:59:59.99 +00:00
79
- INSERT INTO [datatypes] ([id], [datetimeoffset_7]) VALUES ( 84, '1984-01-24T04:20:00.0000000-08:00' ) -- 1984-01-24 04:20:00.0000000 -08:00
79
+ INSERT INTO [datatypes] ([id], [datetimeoffset_7]) VALUES ( 84, '1984-01-24T04:20:00.1234567-08:00' ) -- 1984-01-24 04:20:00.1234567 -08:00
80
80
  INSERT INTO [datatypes] ([id], [datetimeoffset_7]) VALUES ( 85, '1984-01-24T04:20:00.0000000Z' ) -- 1984-01-24 04:20:00.0000000 +00:00
81
81
  INSERT INTO [datatypes] ([id], [datetimeoffset_7]) VALUES ( 86, '9999-12-31T23:59:59.9999999Z' ) -- 9999-12-31 23:59:59.9999999 +00:00
82
82
  INSERT INTO [datatypes] ([id], [decimal_9_2]) VALUES ( 91, 12345.01 )
@@ -120,10 +120,10 @@ INSERT INTO [datatypes] ([id], [smallmoney]) VALUES ( 251, 4.20 )
120
120
  INSERT INTO [datatypes] ([id], [smallmoney]) VALUES ( 252, -214748.3647 )
121
121
  INSERT INTO [datatypes] ([id], [smallmoney]) VALUES ( 253, 214748.3646 )
122
122
  INSERT INTO [datatypes] ([id], [text]) VALUES ( 271, 'test text' )
123
- INSERT INTO [datatypes] ([id], [time_2]) VALUES ( 281, '1901-01-01T15:45:00.0100001Z' ) -- 15:45:00.01
124
- INSERT INTO [datatypes] ([id], [time_2]) VALUES ( 282, '1984-01-24T04:20:00.0000001-08:00' ) -- 04:20:00.00
125
- INSERT INTO [datatypes] ([id], [time_7]) VALUES ( 283, '1901-01-01T15:45:00.0100001Z' ) -- 15:45:00.0100001
126
- INSERT INTO [datatypes] ([id], [time_7]) VALUES ( 284, '1984-01-24T04:20:00.0000001-08:00' ) -- 04:20:00.0000001
123
+ INSERT INTO [datatypes] ([id], [time_2]) VALUES ( 281, '15:45:00.709714966' ) -- 15:45:00.71
124
+ INSERT INTO [datatypes] ([id], [time_2]) VALUES ( 282, '04:20:00.288321545' ) -- 04:20:00.29
125
+ INSERT INTO [datatypes] ([id], [time_7]) VALUES ( 283, '15:45:00.709714966' ) -- 15:45:00.709714900
126
+ INSERT INTO [datatypes] ([id], [time_7]) VALUES ( 284, '04:20:00.288321545' ) -- 04:20:00.288321500
127
127
  INSERT INTO [datatypes] ([id], [tinyint]) VALUES ( 301, 0 )
128
128
  INSERT INTO [datatypes] ([id], [tinyint]) VALUES ( 302, 255 )
129
129
  INSERT INTO [datatypes] ([id], [uniqueidentifier]) VALUES ( 311, NEWID() )
@@ -1,16 +1,16 @@
1
1
 
2
2
  /*
3
3
 
4
- * Binary Data - Our test binary data is a 1 pixel gif. The basic (raw) data is below. Quoting this data
5
- would involve this (encode) method and be (encoded) with the 0x prefix for raw SQL. In other clients the
4
+ * Binary Data - Our test binary data is a 1 pixel gif. The basic (raw) data is below. Quoting this data
5
+ would involve this (encode) method and be (encoded) with the 0x prefix for raw SQL. In other clients the
6
6
  (raw_db) value without the 0x prefix would need to be (packed) again yield the original (raw) value.
7
-
7
+
8
8
  (raw) - "GIF89a\001\000\001\000\221\000\000\377\377\377\377\377\377\376\001\002\000\000\000!\371\004\004\024\000\377\000,\000\000\000\000\001\000\001\000\000\002\002D\001\000;"
9
9
  (encode) - "0x#{raw.unpack("H*")[0]}"
10
10
  (encoded) - "0x47494638396101000100910000fffffffffffffe010200000021f904041400ff002c00000000010001000002024401003b"
11
11
  (raw_db) - "47494638396101000100910000fffffffffffffe010200000021f904041400ff002c00000000010001000002024401003b"
12
12
  (packed) - [raw_db].pack('H*')
13
-
13
+
14
14
  */
15
15
 
16
16
  CREATE TABLE [dbo].[datatypes] (
@@ -70,13 +70,13 @@ INSERT INTO [datatypes] ([id], [date]) VALUES ( 52, '9999-12-31' )
70
70
  INSERT INTO [datatypes] ([id], [datetime]) VALUES ( 61, '1753-01-01T00:00:00.000' )
71
71
  INSERT INTO [datatypes] ([id], [datetime]) VALUES ( 62, '9999-12-31T23:59:59.997' )
72
72
  INSERT INTO [datatypes] ([id], [datetime]) VALUES ( 63, '2010-01-01T12:34:56.123' )
73
- INSERT INTO [datatypes] ([id], [datetime2_7]) VALUES ( 71, '0001-01-01T00:00:00.0000000Z' )
74
- INSERT INTO [datatypes] ([id], [datetime2_7]) VALUES ( 72, '1984-01-24T04:20:00.0000000-08:00' )
75
- INSERT INTO [datatypes] ([id], [datetime2_7]) VALUES ( 73, '9999-12-31T23:59:59.9999999Z' )
76
- INSERT INTO [datatypes] ([id], [datetimeoffset_2]) VALUES ( 81, '1984-01-24T04:20:00.0000000-08:00' ) -- 1984-01-24 04:20:00.00 -08:00
73
+ INSERT INTO [datatypes] ([id], [datetime2_7]) VALUES ( 71, '0001-01-01 00:00:00.0000000' )
74
+ INSERT INTO [datatypes] ([id], [datetime2_7]) VALUES ( 72, '1984-01-24 04:20:00.0000000' )
75
+ INSERT INTO [datatypes] ([id], [datetime2_7]) VALUES ( 73, '9999-12-31 23:59:59.9999999' )
76
+ INSERT INTO [datatypes] ([id], [datetimeoffset_2]) VALUES ( 81, '1984-01-24T04:20:00.1234567-08:00' ) -- 1984-01-24 04:20:00.00 -08:00
77
77
  INSERT INTO [datatypes] ([id], [datetimeoffset_2]) VALUES ( 82, '1984-01-24T04:20:00.0000000Z' ) -- 1984-01-24 04:20:00.00 +00:00
78
78
  INSERT INTO [datatypes] ([id], [datetimeoffset_2]) VALUES ( 83, '9999-12-31T23:59:59.9999999Z' ) -- 9999-12-31 23:59:59.99 +00:00
79
- INSERT INTO [datatypes] ([id], [datetimeoffset_7]) VALUES ( 84, '1984-01-24T04:20:00.0000000-08:00' ) -- 1984-01-24 04:20:00.0000000 -08:00
79
+ INSERT INTO [datatypes] ([id], [datetimeoffset_7]) VALUES ( 84, '1984-01-24T04:20:00.1234567-08:00' ) -- 1984-01-24 04:20:00.1234567 -08:00
80
80
  INSERT INTO [datatypes] ([id], [datetimeoffset_7]) VALUES ( 85, '1984-01-24T04:20:00.0000000Z' ) -- 1984-01-24 04:20:00.0000000 +00:00
81
81
  INSERT INTO [datatypes] ([id], [datetimeoffset_7]) VALUES ( 86, '9999-12-31T23:59:59.9999999Z' ) -- 9999-12-31 23:59:59.9999999 +00:00
82
82
  INSERT INTO [datatypes] ([id], [decimal_9_2]) VALUES ( 91, 12345.01 )
@@ -120,10 +120,10 @@ INSERT INTO [datatypes] ([id], [smallmoney]) VALUES ( 251, 4.20 )
120
120
  INSERT INTO [datatypes] ([id], [smallmoney]) VALUES ( 252, -214748.3647 )
121
121
  INSERT INTO [datatypes] ([id], [smallmoney]) VALUES ( 253, 214748.3646 )
122
122
  INSERT INTO [datatypes] ([id], [text]) VALUES ( 271, 'test text' )
123
- INSERT INTO [datatypes] ([id], [time_2]) VALUES ( 281, '1901-01-01T15:45:00.0100001Z' ) -- 15:45:00.01
124
- INSERT INTO [datatypes] ([id], [time_2]) VALUES ( 282, '1984-01-24T04:20:00.0000001-08:00' ) -- 04:20:00.00
125
- INSERT INTO [datatypes] ([id], [time_7]) VALUES ( 283, '1901-01-01T15:45:00.0100001Z' ) -- 15:45:00.0100001
126
- INSERT INTO [datatypes] ([id], [time_7]) VALUES ( 284, '1984-01-24T04:20:00.0000001-08:00' ) -- 04:20:00.0000001
123
+ INSERT INTO [datatypes] ([id], [time_2]) VALUES ( 281, '15:45:00.709714966' ) -- 15:45:00.71
124
+ INSERT INTO [datatypes] ([id], [time_2]) VALUES ( 282, '04:20:00.288321545' ) -- 04:20:00.29
125
+ INSERT INTO [datatypes] ([id], [time_7]) VALUES ( 283, '15:45:00.709714966' ) -- 15:45:00.709714900
126
+ INSERT INTO [datatypes] ([id], [time_7]) VALUES ( 284, '04:20:00.288321545' ) -- 04:20:00.288321500
127
127
  INSERT INTO [datatypes] ([id], [tinyint]) VALUES ( 301, 0 )
128
128
  INSERT INTO [datatypes] ([id], [tinyint]) VALUES ( 302, 255 )
129
129
  INSERT INTO [datatypes] ([id], [uniqueidentifier]) VALUES ( 311, NEWID() )
@@ -1,16 +1,16 @@
1
1
 
2
2
  /*
3
3
 
4
- * Binary Data - Our test binary data is a 1 pixel gif. The basic (raw) data is below. Quoting this data
5
- would involve this (encode) method and be (encoded) with the 0x prefix for raw SQL. In other clients the
4
+ * Binary Data - Our test binary data is a 1 pixel gif. The basic (raw) data is below. Quoting this data
5
+ would involve this (encode) method and be (encoded) with the 0x prefix for raw SQL. In other clients the
6
6
  (raw_db) value without the 0x prefix would need to be (packed) again yield the original (raw) value.
7
-
7
+
8
8
  (raw) - "GIF89a\001\000\001\000\221\000\000\377\377\377\377\377\377\376\001\002\000\000\000!\371\004\004\024\000\377\000,\000\000\000\000\001\000\001\000\000\002\002D\001\000;"
9
9
  (encode) - "0x#{raw.unpack("H*")[0]}"
10
10
  (encoded) - "0x47494638396101000100910000fffffffffffffe010200000021f904041400ff002c00000000010001000002024401003b"
11
11
  (raw_db) - "47494638396101000100910000fffffffffffffe010200000021f904041400ff002c00000000010001000002024401003b"
12
12
  (packed) - [raw_db].pack('H*')
13
-
13
+
14
14
  */
15
15
 
16
16
  CREATE TABLE [datatypes] (
@@ -71,12 +71,12 @@ INSERT INTO [datatypes] ([id], [datetime]) VALUES ( 61, '1753-01-01T00:
71
71
  INSERT INTO [datatypes] ([id], [datetime]) VALUES ( 62, '9999-12-31T23:59:59.997' )
72
72
  INSERT INTO [datatypes] ([id], [datetime]) VALUES ( 63, '2010-01-01T12:34:56.123' )
73
73
  -- INSERT INTO [datatypes] ([id], [datetime2_7]) VALUES ( 71, '0001-01-01T00:00:00.0000000Z' )
74
- -- INSERT INTO [datatypes] ([id], [datetime2_7]) VALUES ( 72, '1984-01-24T04:20:00.0000000-08:00' )
74
+ -- INSERT INTO [datatypes] ([id], [datetime2_7]) VALUES ( 72, '1984-01-24T04:20:00.1234567-08:00' )
75
75
  -- INSERT INTO [datatypes] ([id], [datetime2_7]) VALUES ( 73, '9999-12-31T23:59:59.9999999Z' )
76
- -- INSERT INTO [datatypes] ([id], [datetimeoffset_2]) VALUES ( 81, '1984-01-24T04:20:00.0000000-08:00' ) -- 1984-01-24 04:20:00.00 -08:00
76
+ -- INSERT INTO [datatypes] ([id], [datetimeoffset_2]) VALUES ( 81, '1984-01-24T04:20:00.1234567-08:00' ) -- 1984-01-24 04:20:00.00 -08:00
77
77
  -- INSERT INTO [datatypes] ([id], [datetimeoffset_2]) VALUES ( 82, '1984-01-24T04:20:00.0000000Z' ) -- 1984-01-24 04:20:00.00 +00:00
78
78
  -- INSERT INTO [datatypes] ([id], [datetimeoffset_2]) VALUES ( 83, '9999-12-31T23:59:59.9999999Z' ) -- 9999-12-31 23:59:59.99 +00:00
79
- -- INSERT INTO [datatypes] ([id], [datetimeoffset_7]) VALUES ( 84, '1984-01-24T04:20:00.0000000-08:00' ) -- 1984-01-24 04:20:00.0000000 -08:00
79
+ -- INSERT INTO [datatypes] ([id], [datetimeoffset_7]) VALUES ( 84, '1984-01-24T04:20:00.1234567-08:00' ) -- 1984-01-24 04:20:00.1234567 -08:00
80
80
  -- INSERT INTO [datatypes] ([id], [datetimeoffset_7]) VALUES ( 85, '1984-01-24T04:20:00.0000000Z' ) -- 1984-01-24 04:20:00.0000000 +00:00
81
81
  -- INSERT INTO [datatypes] ([id], [datetimeoffset_7]) VALUES ( 86, '9999-12-31T23:59:59.9999999Z' ) -- 9999-12-31 23:59:59.9999999 +00:00
82
82
  INSERT INTO [datatypes] ([id], [decimal_9_2]) VALUES ( 91, 12345.01 )
data/test/schema_test.rb CHANGED
@@ -241,35 +241,164 @@ class SchemaTest < TinyTds::TestCase
241
241
 
242
242
  describe 'for 2008 and up' do
243
243
 
244
- # These data types always come back as SYBTEXT and there is no way I can
245
- # find out the column's human readable name.
246
- #
247
- # * [date]
248
- # * [datetime2]
249
- # * [datetimeoffset]
250
- # * [time]
251
- #
252
- # I have tried the following and I only get back either "char" or 0/null.
253
- #
254
- # rb_warn("SYBTEXT: dbprtype: %s", dbprtype(coltype));
255
- # rb_warn("SYBTEXT: dbcolutype: %s", dbcolutype(rwrap->client, col));
256
- # rb_warn("SYBTEXT: dbcolutype: %ld", dbcolutype(rwrap->client, col));
244
+ it 'casts date' do
245
+ # 0001-01-01
246
+ v = find_value 51, :date
247
+ if @client.tds_73?
248
+ assert_instance_of Date, v
249
+ assert_equal 1, v.year, 'Year'
250
+ assert_equal 1, v.month, 'Month'
251
+ assert_equal 1, v.day, 'Day'
252
+ else
253
+ assert_equal '0001-01-01', v
254
+ end
255
+ # 9999-12-31
256
+ v = find_value 52, :date
257
+ if @client.tds_73?
258
+ assert_instance_of Date, v
259
+ assert_equal 9999, v.year, 'Year'
260
+ assert_equal 12, v.month, 'Month'
261
+ assert_equal 31, v.day, 'Day'
262
+ else
263
+ assert_equal '9999-12-31', v
264
+ end
265
+ end
266
+
267
+ it 'casts time' do
268
+ # 15:45:00.709714966
269
+ v = find_value 281, :time_2
270
+ if @client.tds_73?
271
+ assert_instance_of Time, v
272
+ assert_equal 1900, v.year, 'Year'
273
+ assert_equal 1, v.month, 'Month'
274
+ assert_equal 1, v.day, 'Day'
275
+ assert_equal 15, v.hour, 'Hour'
276
+ assert_equal 45, v.min, 'Minute'
277
+ assert_equal 0, v.sec, 'Second'
278
+ assert_equal 710000, v.usec, 'Microseconds'
279
+ assert_equal 710000000, v.nsec, 'Nanoseconds'
280
+ else
281
+ assert_equal '15:45:00.71', v
282
+ end
283
+ # 04:20:00.288321545
284
+ v = find_value 282, :time_2
285
+ if @client.tds_73?
286
+ assert_instance_of Time, v
287
+ assert_equal 1900, v.year, 'Year'
288
+ assert_equal 1, v.month, 'Month'
289
+ assert_equal 1, v.day, 'Day'
290
+ assert_equal 4, v.hour, 'Hour'
291
+ assert_equal 20, v.min, 'Minute'
292
+ assert_equal 0, v.sec, 'Second'
293
+ assert_equal 290000, v.usec, 'Microseconds'
294
+ assert_equal 290000000, v.nsec, 'Nanoseconds'
295
+ else
296
+ assert_equal '04:20:00.29', v
297
+ end
298
+ # 15:45:00.709714966
299
+ v = find_value 283, :time_7
300
+ if @client.tds_73?
301
+ assert_instance_of Time, v
302
+ assert_equal 1900, v.year, 'Year'
303
+ assert_equal 1, v.month, 'Month'
304
+ assert_equal 1, v.day, 'Day'
305
+ assert_equal 15, v.hour, 'Hour'
306
+ assert_equal 45, v.min, 'Minute'
307
+ assert_equal 0, v.sec, 'Second'
308
+ assert_equal 709715, v.usec, 'Microseconds'
309
+ assert_equal 709715000, v.nsec, 'Nanoseconds'
310
+ else
311
+ assert_equal '15:45:00.7097150', v
312
+ end
313
+ # 04:20:00.288321545
314
+ v = find_value 284, :time_7
315
+ if @client.tds_73?
316
+ assert_instance_of Time, v
317
+ assert_equal 1900, v.year, 'Year'
318
+ assert_equal 1, v.month, 'Month'
319
+ assert_equal 1, v.day, 'Day'
320
+ assert_equal 4, v.hour, 'Hour'
321
+ assert_equal 20, v.min, 'Minute'
322
+ assert_equal 0, v.sec, 'Second'
323
+ assert_equal 288321, v.usec, 'Microseconds'
324
+ assert_equal 288321500, v.nsec, 'Nanoseconds'
325
+ else
326
+ assert_equal '04:20:00.2883215', v
327
+ end
328
+ end
329
+
330
+ it 'casts datetime2' do
331
+ # 0001-01-01 00:00:00.0000000
332
+ v = find_value 71, :datetime2_7
333
+ if @client.tds_73?
334
+ assert_instance_of Time, v
335
+ assert_equal 1, v.year, 'Year'
336
+ assert_equal 1, v.month, 'Month'
337
+ assert_equal 1, v.day, 'Day'
338
+ assert_equal 0, v.hour, 'Hour'
339
+ assert_equal 0, v.min, 'Minute'
340
+ assert_equal 0, v.sec, 'Second'
341
+ assert_equal 0, v.usec, 'Microseconds'
342
+ assert_equal 0, v.nsec, 'Nanoseconds'
343
+ else
344
+ assert_equal '0001-01-01 00:00:00.0000000', v
345
+ end
346
+ # 1984-01-24 04:20:00.0000000
347
+ v = find_value 72, :datetime2_7
348
+ if @client.tds_73?
349
+ assert_instance_of Time, v
350
+ assert_equal 1984, v.year, 'Year'
351
+ assert_equal 1, v.month, 'Month'
352
+ assert_equal 24, v.day, 'Day'
353
+ assert_equal 4, v.hour, 'Hour'
354
+ assert_equal 20, v.min, 'Minute'
355
+ assert_equal 0, v.sec, 'Second'
356
+ assert_equal 0, v.usec, 'Microseconds'
357
+ assert_equal 0, v.nsec, 'Nanoseconds'
358
+ else
359
+ assert_equal '1984-01-24 04:20:00.0000000', v
360
+ end
361
+ # 9999-12-31 23:59:59.9999999
362
+ v = find_value 73, :datetime2_7
363
+ if @client.tds_73?
364
+ assert_instance_of Time, v
365
+ assert_equal 9999, v.year, 'Year'
366
+ assert_equal 12, v.month, 'Month'
367
+ assert_equal 31, v.day, 'Day'
368
+ assert_equal 23, v.hour, 'Hour'
369
+ assert_equal 59, v.min, 'Minute'
370
+ assert_equal 59, v.sec, 'Second'
371
+ assert_equal 999999, v.usec, 'Microseconds'
372
+ assert_equal 999999900, v.nsec, 'Nanoseconds'
373
+ else
374
+ assert_equal '9999-12-31 23:59:59.9999999', v
375
+ end
376
+ end
377
+
378
+ it 'casts datetimeoffset' do
379
+ # 1984-01-24T04:20:00.1234567-08:00
380
+ v = find_value 84, :datetimeoffset_7
381
+ if @client.tds_73?
382
+ assertions = lambda {
383
+ assert_instance_of Time, v
384
+ assert_equal 1984, v.year, 'Year'
385
+ assert_equal 1, v.month, 'Month'
386
+ assert_equal 24, v.day, 'Day'
387
+ assert_equal 4, v.hour, 'Hour'
388
+ assert_equal 20, v.min, 'Minute'
389
+ assert_equal 0, v.sec, 'Second'
390
+ assert_equal 123456, v.usec, 'Microseconds'
391
+ assert_equal 123456700, v.nsec, 'Nanoseconds'
392
+ assert_equal -480, v.utc_offset, 'Offset'
393
+ }
394
+ assertions.call
395
+ v = find_value 84, :datetimeoffset_7, timezone: :local
396
+ assertions.call # Ignores timezone query option.
397
+ else
398
+ assert_equal '1984-01-24 04:20:00.1234567 -08:00', v
399
+ end
400
+ end
257
401
 
258
- # it 'casts date' do
259
- # value = find_value 51, :date
260
- # assert_equal '', value
261
- # end
262
- #
263
- # it 'casts datetime2' do
264
- # value = find_value 72, :datetime2_7
265
- # assert_equal '', value
266
- # end
267
- #
268
- # it 'casts datetimeoffset' do
269
- # value = find_value 81, :datetimeoffset_2
270
- # assert_equal '', value
271
- # end
272
- #
273
402
  # it 'casts geography' do
274
403
  # value = find_value 111, :geography
275
404
  # assert_equal '', value
@@ -284,11 +413,6 @@ class SchemaTest < TinyTds::TestCase
284
413
  # value = find_value 131, :hierarchyid
285
414
  # assert_equal '', value
286
415
  # end
287
- #
288
- # it 'casts time' do
289
- # value = find_value 283, :time_7
290
- # assert_equal '', value
291
- # end
292
416
 
293
417
  end if sqlserver_2008? || sqlserver_2014? || sqlserver_azure?
294
418