@@ -703,6 +703,99 @@ public void GetSchemaTable(string column, string table, int columnSize, Type dat
703703 }
704704#endif
705705
706+ #if ! BASELINE
707+ [ Theory ]
708+ [ InlineData ( "Bit1" , "datatypes_bits" , "BIT" , 1 , typeof ( ulong ) , "N" , - 1 , 0 ) ]
709+ [ InlineData ( "Bit32" , "datatypes_bits" , "BIT" , 32 , typeof ( ulong ) , "N" , - 1 , 0 ) ]
710+ [ InlineData ( "Bit64" , "datatypes_bits" , "BIT" , 64 , typeof ( ulong ) , "N" , - 1 , 0 ) ]
711+ [ InlineData ( "Binary" , "datatypes_blobs" , "BLOB" , 100 , typeof ( byte [ ] ) , "N" , - 1 , 0 ) ]
712+ [ InlineData ( "VarBinary" , "datatypes_blobs" , "BLOB" , 100 , typeof ( byte [ ] ) , "N" , - 1 , 0 ) ]
713+ [ InlineData ( "TinyBlob" , "datatypes_blobs" , "BLOB" , 255 , typeof ( byte [ ] ) , "N" , - 1 , 0 ) ]
714+ [ InlineData ( "Blob" , "datatypes_blobs" , "BLOB" , 65535 , typeof ( byte [ ] ) , "LN" , - 1 , 0 ) ]
715+ [ InlineData ( "MediumBlob" , "datatypes_blobs" , "BLOB" , 16777215 , typeof ( byte [ ] ) , "LN" , - 1 , 0 ) ]
716+ [ InlineData ( "LongBlob" , "datatypes_blobs" , "BLOB" , int . MaxValue , typeof ( byte [ ] ) , "LN" , - 1 , 0 ) ]
717+ [ InlineData ( "guidbin" , "datatypes_blobs" , "BLOB" , 16 , typeof ( byte [ ] ) , "N" , - 1 , 0 ) ]
718+ [ InlineData ( "rowid" , "datatypes_bools" , "INT" , 11 , typeof ( int ) , "AK" , - 1 , 0 ) ]
719+ [ InlineData ( "Boolean" , "datatypes_bools" , "BOOL" , 1 , typeof ( bool ) , "N" , - 1 , 0 ) ]
720+ [ InlineData ( "TinyInt1" , "datatypes_bools" , "BOOL" , 1 , typeof ( bool ) , "N" , - 1 , 0 ) ]
721+ [ InlineData ( "size" , "datatypes_enums" , "ENUM" , 7 , typeof ( string ) , "N" , - 1 , 0 ) ]
722+ [ InlineData ( "color" , "datatypes_enums" , "ENUM" , 6 , typeof ( string ) , "" , - 1 , 0 ) ]
723+ [ InlineData ( "char38" , "datatypes_guids" , "CHAR(38)" , 38 , typeof ( string ) , "N" , - 1 , 0 ) ]
724+ [ InlineData ( "char38bin" , "datatypes_guids" , "CHAR(38)" , 38 , typeof ( string ) , "N" , - 1 , 0 ) ]
725+ [ InlineData ( "text" , "datatypes_guids" , "VARCHAR" , 65535 , typeof ( string ) , "LN" , - 1 , 0 ) ]
726+ [ InlineData ( "blob" , "datatypes_guids" , "BLOB" , 65535 , typeof ( byte [ ] ) , "LN" , - 1 , 0 ) ]
727+ [ InlineData ( "SByte" , "datatypes_integers" , "TINYINT" , 4 , typeof ( sbyte ) , "N" , - 1 , 0 ) ]
728+ [ InlineData ( "Byte" , "datatypes_integers" , "TINYINT" , 3 , typeof ( byte ) , "N" , - 1 , 0 ) ]
729+ [ InlineData ( "Int16" , "datatypes_integers" , "SMALLINT" , 6 , typeof ( short ) , "N" , - 1 , 0 ) ]
730+ [ InlineData ( "UInt16" , "datatypes_integers" , "SMALLINT" , 5 , typeof ( ushort ) , "N" , - 1 , 0 ) ]
731+ [ InlineData ( "Int24" , "datatypes_integers" , "MEDIUMINT" , 9 , typeof ( int ) , "N" , - 1 , 0 ) ]
732+ [ InlineData ( "UInt24" , "datatypes_integers" , "MEDIUMINT" , 8 , typeof ( uint ) , "N" , - 1 , 0 ) ]
733+ [ InlineData ( "Int32" , "datatypes_integers" , "INT" , 11 , typeof ( int ) , "N" , - 1 , 0 ) ]
734+ [ InlineData ( "UInt32" , "datatypes_integers" , "INT" , 10 , typeof ( uint ) , "N" , - 1 , 0 ) ]
735+ [ InlineData ( "Int64" , "datatypes_integers" , "BIGINT" , 20 , typeof ( long ) , "N" , - 1 , 0 ) ]
736+ [ InlineData ( "UInt64" , "datatypes_integers" , "BIGINT" , 20 , typeof ( ulong ) , "N" , - 1 , 0 ) ]
737+ [ InlineData ( "value" , "datatypes_json_core" , "JSON" , int . MaxValue , typeof ( string ) , "LN" , - 1 , 0 ) ]
738+ [ InlineData ( "Single" , "datatypes_reals" , "FLOAT" , 12 , typeof ( float ) , "N" , - 1 , 31 ) ]
739+ [ InlineData ( "Double" , "datatypes_reals" , "DOUBLE" , 22 , typeof ( double ) , "N" , - 1 , 31 ) ]
740+ [ InlineData ( "SmallDecimal" , "datatypes_reals" , "DECIMAL" , 7 , typeof ( decimal ) , "N" , 5 , 2 ) ]
741+ [ InlineData ( "MediumDecimal" , "datatypes_reals" , "DECIMAL" , 30 , typeof ( decimal ) , "N" , 28 , 8 ) ]
742+ [ InlineData ( "BigDecimal" , "datatypes_reals" , "DECIMAL" , 52 , typeof ( decimal ) , "N" , 50 , 30 ) ]
743+ [ InlineData ( "value" , "datatypes_set" , "SET" , 12 , typeof ( string ) , "N" , - 1 , 0 ) ]
744+ [ InlineData ( "utf8" , "datatypes_strings" , "VARCHAR" , 300 , typeof ( string ) , "N" , - 1 , 0 ) ]
745+ [ InlineData ( "utf8bin" , "datatypes_strings" , "VARCHAR" , 300 , typeof ( string ) , "N" , - 1 , 0 ) ]
746+ [ InlineData ( "latin1" , "datatypes_strings" , "VARCHAR" , 300 , typeof ( string ) , "N" , - 1 , 0 ) ]
747+ [ InlineData ( "latin1bin" , "datatypes_strings" , "VARCHAR" , 300 , typeof ( string ) , "N" , - 1 , 0 ) ]
748+ [ InlineData ( "cp1251" , "datatypes_strings" , "VARCHAR" , 300 , typeof ( string ) , "N" , - 1 , 0 ) ]
749+ [ InlineData ( "guid" , "datatypes_strings" , "CHAR(36)" , 36 , typeof ( Guid ) , "N" , - 1 , 0 ) ]
750+ [ InlineData ( "guidbin" , "datatypes_strings" , "CHAR(36)" , 36 , typeof ( Guid ) , "N" , - 1 , 0 ) ]
751+ [ InlineData ( "Date" , "datatypes_times" , "DATE" , 10 , typeof ( DateTime ) , "N" , - 1 , 0 ) ]
752+ [ InlineData ( "DateTime" , "datatypes_times" , "DATETIME" , 26 , typeof ( DateTime ) , "N" , - 1 , 6 ) ]
753+ [ InlineData ( "Timestamp" , "datatypes_times" , "TIMESTAMP" , 26 , typeof ( DateTime ) , "N" , - 1 , 6 ) ]
754+ [ InlineData ( "Time" , "datatypes_times" , "TIME" , 17 , typeof ( TimeSpan ) , "N" , - 1 , 6 ) ]
755+ [ InlineData ( "Year" , "datatypes_times" , "YEAR" , 4 , typeof ( int ) , "N" , - 1 , 0 ) ]
756+ public void GetColumnSchema ( string column , string table , string dataTypeName , int columnSize , Type dataType , string flags , int precision , int scale )
757+ {
758+ if ( table == "datatypes_json_core" && ! AppConfig . SupportsJson )
759+ return ;
760+
761+ var isAutoIncrement = flags . IndexOf ( 'A' ) != - 1 ;
762+ var isKey = flags . IndexOf ( 'K' ) != - 1 ;
763+ var isLong = flags . IndexOf ( 'L' ) != - 1 ;
764+ var allowDbNull = flags . IndexOf ( 'N' ) != - 1 ;
765+ var realPrecision = precision == - 1 ? default ( int ? ) : precision ;
766+
767+ using ( var command = m_database . Connection . CreateCommand ( ) )
768+ {
769+ command . CommandText = $ "select `{ column } ` from `{ table } `;";
770+ using ( var reader = command . ExecuteReader ( ) )
771+ {
772+ var columns = reader . GetColumnSchema ( ) ;
773+ Assert . Single ( columns ) ;
774+ var schema = columns [ 0 ] ;
775+ Assert . Equal ( allowDbNull , schema . AllowDBNull ) ;
776+ Assert . Equal ( column , schema . BaseColumnName ) ;
777+ Assert . Equal ( m_database . Connection . Database , schema . BaseSchemaName ) ;
778+ Assert . Equal ( table , schema . BaseTableName ) ;
779+ Assert . Equal ( column , schema . ColumnName ) ;
780+ Assert . Equal ( 0 , schema . ColumnOrdinal ) ;
781+ Assert . Equal ( dataType , schema . DataType ) ;
782+ Assert . Equal ( dataTypeName , schema . DataTypeName ) ;
783+ Assert . Equal ( columnSize , schema . ColumnSize ) ;
784+ Assert . False ( schema . IsAliased . Value ) ;
785+ Assert . Equal ( isAutoIncrement , schema . IsAutoIncrement ) ;
786+ Assert . False ( schema . IsExpression . Value ) ;
787+ Assert . False ( schema . IsHidden . Value ) ;
788+ Assert . Equal ( isKey , schema . IsKey ) ;
789+ Assert . Equal ( isLong , schema . IsLong ) ;
790+ Assert . False ( schema . IsReadOnly . Value ) ;
791+ Assert . False ( schema . IsUnique . Value ) ;
792+ Assert . Equal ( realPrecision , schema . NumericPrecision ) ;
793+ Assert . Equal ( scale , schema . NumericScale ) ;
794+ }
795+ }
796+ }
797+ #endif
798+
706799 private static byte [ ] CreateByteArray ( int size )
707800 {
708801 var data = new byte [ size ] ;
0 commit comments