File tree Expand file tree Collapse file tree 2 files changed +28
-2
lines changed Expand file tree Collapse file tree 2 files changed +28
-2
lines changed Original file line number Diff line number Diff line change 292
292
expect ( @test_result [ 'date_time_test' ] . strftime ( "%Y-%m-%d %H:%M:%S" ) ) . to eql ( '2010-04-04 11:44:00' )
293
293
end
294
294
295
+ it "should return Time values with microseconds" do
296
+ now = Time . now
297
+ if RUBY_VERSION =~ /1.8/ || @client . server_info [ :id ] / 100 < 506
298
+ result = @client . query ( "SELECT CAST('#{ now . strftime ( '%F %T %z' ) } ' AS DATETIME) AS a" )
299
+ expect ( result . first [ 'a' ] . strftime ( '%F %T %z' ) ) . to eql ( now . strftime ( '%F %T %z' ) )
300
+ else
301
+ result = @client . query ( "SELECT CAST('#{ now . strftime ( '%F %T.%6N %z' ) } ' AS DATETIME(6)) AS a" )
302
+ # microseconds is 6 digits after the decimal, but only test on 5 significant figures
303
+ expect ( result . first [ 'a' ] . strftime ( '%F %T.%5N %z' ) ) . to eql ( now . strftime ( '%F %T.%5N %z' ) )
304
+ end
305
+ end
306
+
307
+ it "should return DateTime values with microseconds" do
308
+ now = DateTime . now
309
+ if RUBY_VERSION =~ /1.8/ || @client . server_info [ :id ] / 100 < 506
310
+ result = @client . query ( "SELECT CAST('#{ now . strftime ( '%F %T %z' ) } ' AS DATETIME) AS a" )
311
+ expect ( result . first [ 'a' ] . strftime ( '%F %T %z' ) ) . to eql ( now . strftime ( '%F %T %z' ) )
312
+ else
313
+ result = @client . query ( "SELECT CAST('#{ now . strftime ( '%F %T.%6N %z' ) } ' AS DATETIME(6)) AS a" )
314
+ # microseconds is 6 digits after the decimal, but only test on 5 significant figures
315
+ expect ( result . first [ 'a' ] . strftime ( '%F %T.%5N %z' ) ) . to eql ( now . strftime ( '%F %T.%5N %z' ) )
316
+ end
317
+ end
318
+
295
319
if 1 . size == 4 # 32bit
296
320
klass = if RUBY_VERSION =~ /1.8/
297
321
DateTime
Original file line number Diff line number Diff line change @@ -150,7 +150,8 @@ def stmt_count
150
150
if RUBY_VERSION =~ /1.8/
151
151
expect ( result . first [ 'a' ] . strftime ( '%F %T %z' ) ) . to eql ( now . strftime ( '%F %T %z' ) )
152
152
else
153
- expect ( result . first [ 'a' ] . strftime ( '%F %T.%6N %z' ) ) . to eql ( now . strftime ( '%F %T.%6N %z' ) )
153
+ # microseconds is six digits after the decimal, but only test on 5 significant figures
154
+ expect ( result . first [ 'a' ] . strftime ( '%F %T.%5N %z' ) ) . to eql ( now . strftime ( '%F %T.%5N %z' ) )
154
155
end
155
156
end
156
157
@@ -161,7 +162,8 @@ def stmt_count
161
162
if RUBY_VERSION =~ /1.8/
162
163
expect ( result . first [ 'a' ] . strftime ( '%F %T %z' ) ) . to eql ( now . strftime ( '%F %T %z' ) )
163
164
else
164
- expect ( result . first [ 'a' ] . strftime ( '%F %T.%6N %z' ) ) . to eql ( now . strftime ( '%F %T.%6N %z' ) )
165
+ # microseconds is six digits after the decimal, but only test on 5 significant figures
166
+ expect ( result . first [ 'a' ] . strftime ( '%F %T.%5N %z' ) ) . to eql ( now . strftime ( '%F %T.%5N %z' ) )
165
167
end
166
168
end
167
169
You can’t perform that action at this time.
0 commit comments