@@ -13,14 +13,20 @@ public class YdbSchemaTests : YdbAdoNetFixture
1313 private readonly string _table1 ;
1414 private readonly string _table2 ;
1515 private readonly string _table3 ;
16- private readonly HashSet < string > _tableNames ;
16+ private readonly string _allTypesTable ;
17+ private readonly string _allTypesTableNullable ;
18+ private readonly HashSet < string > _allTableNames ;
19+ private readonly HashSet < string > _simpleTableNames ;
1720
1821 public YdbSchemaTests ( YdbFactoryFixture fixture ) : base ( fixture )
1922 {
2023 _table1 = $ "a/b/{ Utils . Net } _{ Random . Shared . Next ( ) } ";
2124 _table2 = $ "a/{ Utils . Net } _{ Random . Shared . Next ( ) } ";
2225 _table3 = $ "{ Utils . Net } _{ Random . Shared . Next ( ) } ";
23- _tableNames = new HashSet < string > { _table1 , _table2 , _table3 } ;
26+ _allTypesTable = $ "allTypesTable_{ Utils . Net } _{ Random . Shared . Next ( ) } ";
27+ _allTypesTableNullable = $ "allTypesTableNullable_{ Utils . Net } _{ Random . Shared . Next ( ) } ";
28+ _allTableNames = new HashSet < string > { _table1 , _table2 , _table3 , _allTypesTable , _allTypesTableNullable } ;
29+ _simpleTableNames = new HashSet < string > { _table1 , _table2 , _table3 } ;
2430 }
2531
2632 [ Fact ]
@@ -32,10 +38,10 @@ public async Task GetSchema_WhenTablesCollection_ReturnAllTables()
3238
3339 foreach ( DataRow row in table . Rows )
3440 {
35- _tableNames . Remove ( row [ "table_name" ] . ToString ( ) ! ) ;
41+ _allTableNames . Remove ( row [ "table_name" ] . ToString ( ) ! ) ;
3642 }
3743
38- Assert . Empty ( _tableNames ) ;
44+ Assert . Empty ( _allTableNames ) ;
3945
4046 var singleTable1 = await ydbConnection . GetSchemaAsync ( "Tables" , new [ ] { _table1 , "TABLE" } ) ;
4147 Assert . Equal ( 1 , singleTable1 . Rows . Count ) ;
@@ -61,14 +67,14 @@ public async Task GetSchema_WhenTablesWithStatsCollection_ReturnAllTables()
6167
6268 foreach ( DataRow row in table . Rows )
6369 {
64- _tableNames . Remove ( row [ "table_name" ] . ToString ( ) ! ) ;
70+ _allTableNames . Remove ( row [ "table_name" ] . ToString ( ) ! ) ;
6571
6672 Assert . NotNull ( row [ "rows_estimate" ] ) ;
6773 Assert . NotNull ( row [ "creation_time" ] ) ;
6874 Assert . NotNull ( row [ "modification_time" ] ) ;
6975 }
7076
71- Assert . Empty ( _tableNames ) ;
77+ Assert . Empty ( _allTableNames ) ;
7278
7379 var singleTable1 = await ydbConnection . GetSchemaAsync ( "TablesWithStats" , new [ ] { _table1 , "TABLE" } ) ;
7480 Assert . Equal ( 1 , singleTable1 . Rows . Count ) ;
@@ -97,7 +103,7 @@ public async Task GetSchema_WhenColumnsCollection_ReturnAllColumns()
97103 {
98104 await using var ydbConnection = await CreateOpenConnectionAsync ( ) ;
99105
100- foreach ( var tableName in _tableNames )
106+ foreach ( var tableName in new [ ] { _table1 , _table2 , _table3 } )
101107 {
102108 var dataTable = await ydbConnection . GetSchemaAsync ( "Columns" , new [ ] { tableName , null } ) ;
103109
@@ -128,7 +134,7 @@ public async Task GetSchema_WhenColumnsCollection_ReturnAllColumns()
128134 CheckColumnB ( rowsB [ i ] ) ;
129135 }
130136
131- foreach ( var tableName in _tableNames )
137+ foreach ( var tableName in _simpleTableNames )
132138 {
133139 var dataTable = await ydbConnection . GetSchemaAsync ( "Columns" , new [ ] { tableName , "a" } ) ;
134140 Assert . Equal ( 1 , dataTable . Rows . Count ) ;
@@ -137,7 +143,7 @@ public async Task GetSchema_WhenColumnsCollection_ReturnAllColumns()
137143 CheckColumnA ( columnA ) ;
138144 }
139145
140- foreach ( var tableName in _tableNames )
146+ foreach ( var tableName in _simpleTableNames )
141147 {
142148 var dataTable = await ydbConnection . GetSchemaAsync ( "Columns" , new [ ] { tableName , "b" } ) ;
143149 Assert . Equal ( 1 , dataTable . Rows . Count ) ;
@@ -167,6 +173,51 @@ void CheckColumnB(DataRow columnB)
167173 }
168174 }
169175
176+ [ Fact ]
177+ public async Task GetSchema_WhenAllTypesTable_ReturnAllTypes ( )
178+ {
179+ await using var ydbConnection = await CreateOpenConnectionAsync ( ) ;
180+ var dataTable = await ydbConnection . GetSchemaAsync ( "Columns" , new [ ] { _allTypesTable , null } ) ;
181+ var dataTableNullable = await ydbConnection . GetSchemaAsync ( "Columns" , new [ ] { _allTypesTableNullable , null } ) ;
182+
183+ Assert . Equal ( 17 , dataTable . Rows . Count ) ;
184+ Assert . Equal ( 17 , dataTableNullable . Rows . Count ) ;
185+
186+ CheckAllColumns ( dataTable , false ) ;
187+ CheckAllColumns ( dataTableNullable , true ) ;
188+ return ;
189+
190+ void CheckAllColumns ( DataTable pDataTable , bool isNullableTable )
191+ {
192+ CheckColumn ( pDataTable . Rows [ 0 ] , "TimestampColumn" , 0 , isNullableTable ) ;
193+ CheckColumn ( pDataTable . Rows [ 1 ] , "Int32Column" , 1 , isNullableTable ) ;
194+ CheckColumn ( pDataTable . Rows [ 2 ] , "BoolColumn" , 2 , isNullableTable ) ;
195+ CheckColumn ( pDataTable . Rows [ 3 ] , "Int64Column" , 3 , isNullableTable ) ;
196+ CheckColumn ( pDataTable . Rows [ 4 ] , "Int16Column" , 4 , isNullableTable ) ;
197+ CheckColumn ( pDataTable . Rows [ 5 ] , "Int8Column" , 5 , isNullableTable ) ;
198+ CheckColumn ( pDataTable . Rows [ 6 ] , "FloatColumn" , 6 , isNullableTable ) ;
199+ CheckColumn ( pDataTable . Rows [ 7 ] , "DoubleColumn" , 7 , isNullableTable ) ;
200+ CheckColumn ( pDataTable . Rows [ 8 ] , "DefaultDecimalColumn" , 8 , isNullableTable , "Decimal(22, 9)" ) ;
201+ CheckColumn ( pDataTable . Rows [ 9 ] , "Uint8Column" , 9 , isNullableTable ) ;
202+ CheckColumn ( pDataTable . Rows [ 10 ] , "Uint16Column" , 10 , isNullableTable ) ;
203+ CheckColumn ( pDataTable . Rows [ 11 ] , "Uint32Column" , 11 , isNullableTable ) ;
204+ CheckColumn ( pDataTable . Rows [ 12 ] , "Uint64Column" , 12 , isNullableTable ) ;
205+ CheckColumn ( pDataTable . Rows [ 13 ] , "TextColumn" , 13 , isNullableTable ) ;
206+ CheckColumn ( pDataTable . Rows [ 14 ] , "BytesColumn" , 14 , isNullableTable ) ;
207+ CheckColumn ( pDataTable . Rows [ 15 ] , "DateColumn" , 15 , isNullableTable ) ;
208+ CheckColumn ( pDataTable . Rows [ 16 ] , "DatetimeColumn" , 16 , isNullableTable ) ;
209+ }
210+
211+ void CheckColumn ( DataRow column , string columnName , int ordinal , bool isNullable , string ? dataType = null )
212+ {
213+ Assert . Equal ( columnName , column [ "column_name" ] ) ;
214+ Assert . Equal ( ordinal , column [ "ordinal_position" ] ) ;
215+ Assert . Equal ( isNullable ? "YES" : "NO" , column [ "is_nullable" ] ) ;
216+ Assert . Equal ( dataType ?? columnName [ ..^ "Column" . Length ] , column [ "data_type" ] ) ;
217+ Assert . Empty ( ( string ) column [ "family_name" ] ) ;
218+ }
219+ }
220+
170221 protected override async Task OnInitializeAsync ( )
171222 {
172223 await using var ydbConnection = await CreateOpenConnectionAsync ( ) ;
@@ -177,6 +228,48 @@ protected override async Task OnInitializeAsync()
177228 CREATE TABLE `{ _table1 } ` (a Int32 NOT NULL, b Int32, PRIMARY KEY(a));
178229 CREATE TABLE `{ _table2 } ` (a Int32 NOT NULL, b Int32, PRIMARY KEY(a));
179230 CREATE TABLE `{ _table3 } ` (a Int32 NOT NULL, b Int32, PRIMARY KEY(a));
231+
232+ CREATE TABLE { _allTypesTable } (
233+ Int32Column Int32 NOT NULL,
234+ BoolColumn Bool NOT NULL,
235+ Int64Column Int64 NOT NULL,
236+ Int16Column Int16 NOT NULL,
237+ Int8Column Int8 NOT NULL,
238+ FloatColumn Float NOT NULL,
239+ DoubleColumn Double NOT NULL,
240+ DefaultDecimalColumn Decimal(22,9) NOT NULL,
241+ Uint8Column Uint8 NOT NULL,
242+ Uint16Column Uint16 NOT NULL,
243+ Uint32Column Uint32 NOT NULL,
244+ Uint64Column Uint64 NOT NULL,
245+ TextColumn Text NOT NULL,
246+ BytesColumn Bytes NOT NULL,
247+ DateColumn Date NOT NULL,
248+ DatetimeColumn Datetime NOT NULL,
249+ TimestampColumn Timestamp NOT NULL,
250+ PRIMARY KEY (Int32Column)
251+ );
252+
253+ CREATE TABLE { _allTypesTableNullable } (
254+ Int32Column Int32,
255+ BoolColumn Bool,
256+ Int64Column Int64,
257+ Int16Column Int16,
258+ Int8Column Int8,
259+ FloatColumn Float,
260+ DoubleColumn Double,
261+ DefaultDecimalColumn Decimal(22,9),
262+ Uint8Column Uint8,
263+ Uint16Column Uint16,
264+ Uint32Column Uint32,
265+ Uint64Column Uint64,
266+ TextColumn Text,
267+ BytesColumn Bytes,
268+ DateColumn Date,
269+ DatetimeColumn Datetime,
270+ TimestampColumn Timestamp,
271+ PRIMARY KEY (Int32Column)
272+ );
180273 "
181274 } . ExecuteNonQueryAsync ( ) ;
182275 }
@@ -191,6 +284,8 @@ protected override async Task OnDisposeAsync()
191284 DROP TABLE `{ _table1 } `;
192285 DROP TABLE `{ _table2 } `;
193286 DROP TABLE `{ _table3 } `;
287+ DROP TABLE `{ _allTypesTable } `;
288+ DROP TABLE `{ _allTypesTableNullable } `;
194289 "
195290 } . ExecuteNonQueryAsync ( ) ;
196291 }
0 commit comments