@@ -8,17 +8,13 @@ namespace DuckDB.NET.Data;
8
8
9
9
internal static class DuckDBSchema
10
10
{
11
- private static readonly string [ ] TableRestrictions =
12
- [ "table_catalog" , "table_schema" , "table_name" , "table_type" ] ;
11
+ private static readonly string [ ] TableRestrictions = [ "table_catalog" , "table_schema" , "table_name" , "table_type" ] ;
13
12
14
- private static readonly string [ ] ColumnRestrictions =
15
- [ "table_catalog" , "table_schema" , "table_name" , "column_name" ] ;
13
+ private static readonly string [ ] ColumnRestrictions = [ "table_catalog" , "table_schema" , "table_name" , "column_name" ] ;
16
14
17
- private static readonly string [ ] ForeignKeyRestrictions =
18
- [ "constraint_catalog" , "constraint_schema" , "table_name" , "constraint_name" ] ;
15
+ private static readonly string [ ] ForeignKeyRestrictions = [ "constraint_catalog" , "constraint_schema" , "table_name" , "constraint_name" ] ;
19
16
20
- private static readonly string [ ] IndexesRestrictions =
21
- [ "index_catalog" , "index_schema" , "table_name" , "index_name" ] ;
17
+ private static readonly string [ ] IndexesRestrictions = [ "index_catalog" , "index_schema" , "table_name" , "index_name" ] ;
22
18
23
19
public static DataTable GetSchema ( DuckDBConnection connection , string collectionName , string ? [ ] ? restrictionValues ) =>
24
20
collectionName . ToUpperInvariant ( ) switch
@@ -92,14 +88,15 @@ private static DataTable GetReservedWords(DuckDBConnection connection)
92
88
{
93
89
using var command = connection . CreateCommand ( ) ;
94
90
command . CommandText = "SELECT keyword_name as ReservedWord FROM duckdb_keywords() WHERE keyword_category = 'reserved'" ;
95
- command . CommandType = CommandType . Text ;
96
91
return GetDataTable ( DbMetaDataCollectionNames . ReservedWords , command ) ;
97
92
}
98
93
99
94
private static DataTable GetTables ( DuckDBConnection connection , string ? [ ] ? restrictionValues )
100
95
{
101
96
if ( restrictionValues ? . Length > TableRestrictions . Length )
97
+ {
102
98
throw new ArgumentException ( "Too many restrictions" , nameof ( restrictionValues ) ) ;
99
+ }
103
100
104
101
const string query = "SELECT table_catalog, table_schema, table_name, table_type FROM information_schema.tables" ;
105
102
@@ -111,7 +108,9 @@ private static DataTable GetTables(DuckDBConnection connection, string?[]? restr
111
108
private static DataTable GetColumns ( DuckDBConnection connection , string ? [ ] ? restrictionValues )
112
109
{
113
110
if ( restrictionValues ? . Length > ColumnRestrictions . Length )
111
+ {
114
112
throw new ArgumentException ( "Too many restrictions" , nameof ( restrictionValues ) ) ;
113
+ }
115
114
116
115
const string query =
117
116
"""
@@ -132,7 +131,9 @@ FROM information_schema.columns
132
131
private static DataTable GetForeignKeys ( DuckDBConnection connection , string ? [ ] ? restrictionValues )
133
132
{
134
133
if ( restrictionValues ? . Length > ForeignKeyRestrictions . Length )
134
+ {
135
135
throw new ArgumentException ( "Too many restrictions" , nameof ( restrictionValues ) ) ;
136
+ }
136
137
137
138
const string query =
138
139
"""
@@ -151,7 +152,9 @@ FROM information_schema.table_constraints
151
152
private static DataTable GetIndexes ( DuckDBConnection connection , string ? [ ] ? restrictionValues )
152
153
{
153
154
if ( restrictionValues ? . Length > IndexesRestrictions . Length )
155
+ {
154
156
throw new ArgumentException ( "Too many restrictions" , nameof ( restrictionValues ) ) ;
157
+ }
155
158
156
159
const string query =
157
160
"""
@@ -169,8 +172,7 @@ FROM duckdb_indexes()
169
172
return GetDataTable ( DuckDbMetaDataCollectionNames . Indexes , command ) ;
170
173
}
171
174
172
- private static DuckDBCommand BuildCommand ( DuckDBConnection connection , string query , string ? [ ] ? restrictions ,
173
- bool addWhere , string [ ] ? restrictionNames )
175
+ private static DuckDBCommand BuildCommand ( DuckDBConnection connection , string query , string ? [ ] ? restrictions , bool addWhere , string [ ] ? restrictionNames )
174
176
{
175
177
var command = connection . CreateCommand ( ) ;
176
178
if ( restrictions is not { Length : > 0 } || restrictionNames == null )
0 commit comments