@@ -582,6 +582,65 @@ public void UseReaderWithoutDisposing()
582
582
throw ex ;
583
583
}
584
584
585
+ [ Theory ]
586
+ #if BASELINE
587
+ [ InlineData ( "null" , typeof ( string ) ) ]
588
+ #else
589
+ [ InlineData ( "null" , typeof ( object ) ) ]
590
+ #endif
591
+ [ InlineData ( "cast(null as char)" , typeof ( string ) ) ]
592
+ [ InlineData ( "1" , typeof ( long ) ) ]
593
+ [ InlineData ( "cast(1 as unsigned)" , typeof ( ulong ) ) ]
594
+ [ InlineData ( "1.0" , typeof ( decimal ) ) ]
595
+ [ InlineData ( "'text'" , typeof ( string ) ) ]
596
+ [ InlineData ( "cast('text' as char(4))" , typeof ( string ) ) ]
597
+ [ InlineData ( "cast('2000-01-02' as date)" , typeof ( DateTime ) ) ]
598
+ [ InlineData ( "cast('2000-01-02 13:45:56' as datetime)" , typeof ( DateTime ) ) ]
599
+ [ InlineData ( "cast('13:45:56' as time)" , typeof ( TimeSpan ) ) ]
600
+ [ InlineData ( "_binary'00112233'" , typeof ( byte [ ] ) ) ]
601
+ [ InlineData ( "sqrt(2)" , typeof ( double ) ) ]
602
+ public void GetFieldType ( string value , Type expectedType )
603
+ {
604
+ using ( var cmd = m_database . Connection . CreateCommand ( ) )
605
+ {
606
+ cmd . CommandText = "select " + value + ";" ;
607
+ using ( var reader = cmd . ExecuteReader ( ) )
608
+ {
609
+ Assert . True ( reader . Read ( ) ) ;
610
+ Assert . Equal ( expectedType , reader . GetFieldType ( 0 ) ) ;
611
+ }
612
+ }
613
+ }
614
+
615
+ [ Theory ]
616
+ #if BASELINE
617
+ [ InlineData ( "null" , "VARCHAR" ) ]
618
+ #else
619
+ [ InlineData ( "null" , "NULL" ) ]
620
+ #endif
621
+ [ InlineData ( "cast(null as char)" , "VARCHAR" ) ]
622
+ [ InlineData ( "1" , "BIGINT" ) ]
623
+ [ InlineData ( "cast(1 as unsigned)" , "BIGINT" ) ]
624
+ [ InlineData ( "1.0" , "DECIMAL" ) ]
625
+ [ InlineData ( "'text'" , "VARCHAR" ) ]
626
+ [ InlineData ( "cast('2000-01-02' as date)" , "DATE" ) ]
627
+ [ InlineData ( "cast('2000-01-02 13:45:56' as datetime)" , "DATETIME" ) ]
628
+ [ InlineData ( "cast('13:45:56' as time)" , "TIME" ) ]
629
+ [ InlineData ( "_binary'00112233'" , "BLOB" ) ]
630
+ [ InlineData ( "sqrt(2)" , "DOUBLE" ) ]
631
+ public void GetDataTypeName ( string value , string expectedDataType )
632
+ {
633
+ using ( var cmd = m_database . Connection . CreateCommand ( ) )
634
+ {
635
+ cmd . CommandText = "select " + value + ";" ;
636
+ using ( var reader = cmd . ExecuteReader ( ) )
637
+ {
638
+ Assert . True ( reader . Read ( ) ) ;
639
+ Assert . Equal ( expectedDataType , reader . GetDataTypeName ( 0 ) ) ;
640
+ }
641
+ }
642
+ }
643
+
585
644
private void UseReaderWithoutDisposingThread ( object obj )
586
645
{
587
646
var data = ( UseReaderWithoutDisposingThreadData ) obj ;
0 commit comments