Skip to content

Commit d32826e

Browse files
committed
Support empty array as restrictionValues
Signed-off-by: Tuomas Hietanen <[email protected]>
1 parent d895afc commit d32826e

File tree

2 files changed

+28
-28
lines changed

2 files changed

+28
-28
lines changed

src/MySqlConnector/Core/SchemaProvider.g.cs

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public async ValueTask<DataTable> GetSchemaAsync(IOBehavior ioBehavior, string c
8383

8484
private Task FillMetaDataCollectionsAsync(IOBehavior ioBehavior, DataTable dataTable, string tableName, string?[]? restrictionValues, CancellationToken cancellationToken)
8585
{
86-
if (restrictionValues is not null)
86+
if (restrictionValues is not null && restrictionValues.Length > 0)
8787
throw new ArgumentException("restrictionValues is not supported for schema 'MetaDataCollections'.", nameof(restrictionValues));
8888

8989
dataTable.TableName = tableName;
@@ -129,7 +129,7 @@ private Task FillMetaDataCollectionsAsync(IOBehavior ioBehavior, DataTable dataT
129129

130130
private async Task FillCharacterSetsAsync(IOBehavior ioBehavior, DataTable dataTable, string tableName, string?[]? restrictionValues, CancellationToken cancellationToken)
131131
{
132-
if (restrictionValues is not null)
132+
if (restrictionValues is not null && restrictionValues.Length > 0)
133133
throw new ArgumentException("restrictionValues is not supported for schema 'CharacterSets'.", nameof(restrictionValues));
134134

135135
dataTable.TableName = tableName;
@@ -146,7 +146,7 @@ private async Task FillCharacterSetsAsync(IOBehavior ioBehavior, DataTable dataT
146146

147147
private async Task FillCollationsAsync(IOBehavior ioBehavior, DataTable dataTable, string tableName, string?[]? restrictionValues, CancellationToken cancellationToken)
148148
{
149-
if (restrictionValues is not null)
149+
if (restrictionValues is not null && restrictionValues.Length > 0)
150150
throw new ArgumentException("restrictionValues is not supported for schema 'Collations'.", nameof(restrictionValues));
151151

152152
dataTable.TableName = tableName;
@@ -165,7 +165,7 @@ private async Task FillCollationsAsync(IOBehavior ioBehavior, DataTable dataTabl
165165

166166
private async Task FillCollationCharacterSetApplicabilityAsync(IOBehavior ioBehavior, DataTable dataTable, string tableName, string?[]? restrictionValues, CancellationToken cancellationToken)
167167
{
168-
if (restrictionValues is not null)
168+
if (restrictionValues is not null && restrictionValues.Length > 0)
169169
throw new ArgumentException("restrictionValues is not supported for schema 'CollationCharacterSetApplicability'.", nameof(restrictionValues));
170170

171171
dataTable.TableName = tableName;
@@ -227,7 +227,7 @@ private async Task FillColumnsAsync(IOBehavior ioBehavior, DataTable dataTable,
227227

228228
private async Task FillDatabasesAsync(IOBehavior ioBehavior, DataTable dataTable, string tableName, string?[]? restrictionValues, CancellationToken cancellationToken)
229229
{
230-
if (restrictionValues is not null)
230+
if (restrictionValues is not null && restrictionValues.Length > 0)
231231
throw new ArgumentException("restrictionValues is not supported for schema 'Databases'.", nameof(restrictionValues));
232232

233233
dataTable.TableName = tableName;
@@ -245,7 +245,7 @@ private async Task FillDatabasesAsync(IOBehavior ioBehavior, DataTable dataTable
245245

246246
private Task FillDataSourceInformationAsync(IOBehavior ioBehavior, DataTable dataTable, string tableName, string?[]? restrictionValues, CancellationToken cancellationToken)
247247
{
248-
if (restrictionValues is not null)
248+
if (restrictionValues is not null && restrictionValues.Length > 0)
249249
throw new ArgumentException("restrictionValues is not supported for schema 'DataSourceInformation'.", nameof(restrictionValues));
250250

251251
dataTable.TableName = tableName;
@@ -277,7 +277,7 @@ private Task FillDataSourceInformationAsync(IOBehavior ioBehavior, DataTable dat
277277

278278
private Task FillDataTypesAsync(IOBehavior ioBehavior, DataTable dataTable, string tableName, string?[]? restrictionValues, CancellationToken cancellationToken)
279279
{
280-
if (restrictionValues is not null)
280+
if (restrictionValues is not null && restrictionValues.Length > 0)
281281
throw new ArgumentException("restrictionValues is not supported for schema 'DataTypes'.", nameof(restrictionValues));
282282

283283
dataTable.TableName = tableName;
@@ -315,7 +315,7 @@ private Task FillDataTypesAsync(IOBehavior ioBehavior, DataTable dataTable, stri
315315

316316
private async Task FillEnginesAsync(IOBehavior ioBehavior, DataTable dataTable, string tableName, string?[]? restrictionValues, CancellationToken cancellationToken)
317317
{
318-
if (restrictionValues is not null)
318+
if (restrictionValues is not null && restrictionValues.Length > 0)
319319
throw new ArgumentException("restrictionValues is not supported for schema 'Engines'.", nameof(restrictionValues));
320320

321321
dataTable.TableName = tableName;
@@ -334,7 +334,7 @@ private async Task FillEnginesAsync(IOBehavior ioBehavior, DataTable dataTable,
334334

335335
private async Task FillKeyColumnUsageAsync(IOBehavior ioBehavior, DataTable dataTable, string tableName, string?[]? restrictionValues, CancellationToken cancellationToken)
336336
{
337-
if (restrictionValues is not null)
337+
if (restrictionValues is not null && restrictionValues.Length > 0)
338338
throw new ArgumentException("restrictionValues is not supported for schema 'KeyColumnUsage'.", nameof(restrictionValues));
339339

340340
dataTable.TableName = tableName;
@@ -359,7 +359,7 @@ private async Task FillKeyColumnUsageAsync(IOBehavior ioBehavior, DataTable data
359359

360360
private async Task FillKeyWordsAsync(IOBehavior ioBehavior, DataTable dataTable, string tableName, string?[]? restrictionValues, CancellationToken cancellationToken)
361361
{
362-
if (restrictionValues is not null)
362+
if (restrictionValues is not null && restrictionValues.Length > 0)
363363
throw new ArgumentException("restrictionValues is not supported for schema 'KeyWords'.", nameof(restrictionValues));
364364

365365
dataTable.TableName = tableName;
@@ -374,7 +374,7 @@ private async Task FillKeyWordsAsync(IOBehavior ioBehavior, DataTable dataTable,
374374

375375
private async Task FillParametersAsync(IOBehavior ioBehavior, DataTable dataTable, string tableName, string?[]? restrictionValues, CancellationToken cancellationToken)
376376
{
377-
if (restrictionValues is not null)
377+
if (restrictionValues is not null && restrictionValues.Length > 0)
378378
throw new ArgumentException("restrictionValues is not supported for schema 'Parameters'.", nameof(restrictionValues));
379379

380380
dataTable.TableName = tableName;
@@ -403,7 +403,7 @@ private async Task FillParametersAsync(IOBehavior ioBehavior, DataTable dataTabl
403403

404404
private async Task FillPartitionsAsync(IOBehavior ioBehavior, DataTable dataTable, string tableName, string?[]? restrictionValues, CancellationToken cancellationToken)
405405
{
406-
if (restrictionValues is not null)
406+
if (restrictionValues is not null && restrictionValues.Length > 0)
407407
throw new ArgumentException("restrictionValues is not supported for schema 'Partitions'.", nameof(restrictionValues));
408408

409409
dataTable.TableName = tableName;
@@ -441,7 +441,7 @@ private async Task FillPartitionsAsync(IOBehavior ioBehavior, DataTable dataTabl
441441

442442
private async Task FillPluginsAsync(IOBehavior ioBehavior, DataTable dataTable, string tableName, string?[]? restrictionValues, CancellationToken cancellationToken)
443443
{
444-
if (restrictionValues is not null)
444+
if (restrictionValues is not null && restrictionValues.Length > 0)
445445
throw new ArgumentException("restrictionValues is not supported for schema 'Plugins'.", nameof(restrictionValues));
446446

447447
dataTable.TableName = tableName;
@@ -465,7 +465,7 @@ private async Task FillPluginsAsync(IOBehavior ioBehavior, DataTable dataTable,
465465

466466
private async Task FillProceduresAsync(IOBehavior ioBehavior, DataTable dataTable, string tableName, string?[]? restrictionValues, CancellationToken cancellationToken)
467467
{
468-
if (restrictionValues is not null)
468+
if (restrictionValues is not null && restrictionValues.Length > 0)
469469
throw new ArgumentException("restrictionValues is not supported for schema 'Procedures'.", nameof(restrictionValues));
470470

471471
dataTable.TableName = tableName;
@@ -498,7 +498,7 @@ private async Task FillProceduresAsync(IOBehavior ioBehavior, DataTable dataTabl
498498

499499
private async Task FillProcessListAsync(IOBehavior ioBehavior, DataTable dataTable, string tableName, string?[]? restrictionValues, CancellationToken cancellationToken)
500500
{
501-
if (restrictionValues is not null)
501+
if (restrictionValues is not null && restrictionValues.Length > 0)
502502
throw new ArgumentException("restrictionValues is not supported for schema 'ProcessList'.", nameof(restrictionValues));
503503

504504
dataTable.TableName = tableName;
@@ -519,7 +519,7 @@ private async Task FillProcessListAsync(IOBehavior ioBehavior, DataTable dataTab
519519

520520
private async Task FillProfilingAsync(IOBehavior ioBehavior, DataTable dataTable, string tableName, string?[]? restrictionValues, CancellationToken cancellationToken)
521521
{
522-
if (restrictionValues is not null)
522+
if (restrictionValues is not null && restrictionValues.Length > 0)
523523
throw new ArgumentException("restrictionValues is not supported for schema 'Profiling'.", nameof(restrictionValues));
524524

525525
dataTable.TableName = tableName;
@@ -550,7 +550,7 @@ private async Task FillProfilingAsync(IOBehavior ioBehavior, DataTable dataTable
550550

551551
private async Task FillReferentialConstraintsAsync(IOBehavior ioBehavior, DataTable dataTable, string tableName, string?[]? restrictionValues, CancellationToken cancellationToken)
552552
{
553-
if (restrictionValues is not null)
553+
if (restrictionValues is not null && restrictionValues.Length > 0)
554554
throw new ArgumentException("restrictionValues is not supported for schema 'ReferentialConstraints'.", nameof(restrictionValues));
555555

556556
dataTable.TableName = tableName;
@@ -574,7 +574,7 @@ private async Task FillReferentialConstraintsAsync(IOBehavior ioBehavior, DataTa
574574

575575
private Task FillReservedWordsAsync(IOBehavior ioBehavior, DataTable dataTable, string tableName, string?[]? restrictionValues, CancellationToken cancellationToken)
576576
{
577-
if (restrictionValues is not null)
577+
if (restrictionValues is not null && restrictionValues.Length > 0)
578578
throw new ArgumentException("restrictionValues is not supported for schema 'ReservedWords'.", nameof(restrictionValues));
579579

580580
dataTable.TableName = tableName;
@@ -590,7 +590,7 @@ private Task FillReservedWordsAsync(IOBehavior ioBehavior, DataTable dataTable,
590590

591591
private async Task FillResourceGroupsAsync(IOBehavior ioBehavior, DataTable dataTable, string tableName, string?[]? restrictionValues, CancellationToken cancellationToken)
592592
{
593-
if (restrictionValues is not null)
593+
if (restrictionValues is not null && restrictionValues.Length > 0)
594594
throw new ArgumentException("restrictionValues is not supported for schema 'ResourceGroups'.", nameof(restrictionValues));
595595

596596
dataTable.TableName = tableName;
@@ -608,7 +608,7 @@ private async Task FillResourceGroupsAsync(IOBehavior ioBehavior, DataTable data
608608

609609
private Task FillRestrictionsAsync(IOBehavior ioBehavior, DataTable dataTable, string tableName, string?[]? restrictionValues, CancellationToken cancellationToken)
610610
{
611-
if (restrictionValues is not null)
611+
if (restrictionValues is not null && restrictionValues.Length > 0)
612612
throw new ArgumentException("restrictionValues is not supported for schema 'Restrictions'.", nameof(restrictionValues));
613613

614614
dataTable.TableName = tableName;
@@ -634,7 +634,7 @@ private Task FillRestrictionsAsync(IOBehavior ioBehavior, DataTable dataTable, s
634634

635635
private async Task FillSchemaPrivilegesAsync(IOBehavior ioBehavior, DataTable dataTable, string tableName, string?[]? restrictionValues, CancellationToken cancellationToken)
636636
{
637-
if (restrictionValues is not null)
637+
if (restrictionValues is not null && restrictionValues.Length > 0)
638638
throw new ArgumentException("restrictionValues is not supported for schema 'SchemaPrivileges'.", nameof(restrictionValues));
639639

640640
dataTable.TableName = tableName;
@@ -699,7 +699,7 @@ private async Task FillTablesAsync(IOBehavior ioBehavior, DataTable dataTable, s
699699

700700
private async Task FillTableConstraintsAsync(IOBehavior ioBehavior, DataTable dataTable, string tableName, string?[]? restrictionValues, CancellationToken cancellationToken)
701701
{
702-
if (restrictionValues is not null)
702+
if (restrictionValues is not null && restrictionValues.Length > 0)
703703
throw new ArgumentException("restrictionValues is not supported for schema 'TableConstraints'.", nameof(restrictionValues));
704704

705705
dataTable.TableName = tableName;
@@ -718,7 +718,7 @@ private async Task FillTableConstraintsAsync(IOBehavior ioBehavior, DataTable da
718718

719719
private async Task FillTablePrivilegesAsync(IOBehavior ioBehavior, DataTable dataTable, string tableName, string?[]? restrictionValues, CancellationToken cancellationToken)
720720
{
721-
if (restrictionValues is not null)
721+
if (restrictionValues is not null && restrictionValues.Length > 0)
722722
throw new ArgumentException("restrictionValues is not supported for schema 'TablePrivileges'.", nameof(restrictionValues));
723723

724724
dataTable.TableName = tableName;
@@ -737,7 +737,7 @@ private async Task FillTablePrivilegesAsync(IOBehavior ioBehavior, DataTable dat
737737

738738
private async Task FillTableSpacesAsync(IOBehavior ioBehavior, DataTable dataTable, string tableName, string?[]? restrictionValues, CancellationToken cancellationToken)
739739
{
740-
if (restrictionValues is not null)
740+
if (restrictionValues is not null && restrictionValues.Length > 0)
741741
throw new ArgumentException("restrictionValues is not supported for schema 'TableSpaces'.", nameof(restrictionValues));
742742

743743
dataTable.TableName = tableName;
@@ -759,7 +759,7 @@ private async Task FillTableSpacesAsync(IOBehavior ioBehavior, DataTable dataTab
759759

760760
private async Task FillTriggersAsync(IOBehavior ioBehavior, DataTable dataTable, string tableName, string?[]? restrictionValues, CancellationToken cancellationToken)
761761
{
762-
if (restrictionValues is not null)
762+
if (restrictionValues is not null && restrictionValues.Length > 0)
763763
throw new ArgumentException("restrictionValues is not supported for schema 'Triggers'.", nameof(restrictionValues));
764764

765765
dataTable.TableName = tableName;
@@ -794,7 +794,7 @@ private async Task FillTriggersAsync(IOBehavior ioBehavior, DataTable dataTable,
794794

795795
private async Task FillUserPrivilegesAsync(IOBehavior ioBehavior, DataTable dataTable, string tableName, string?[]? restrictionValues, CancellationToken cancellationToken)
796796
{
797-
if (restrictionValues is not null)
797+
if (restrictionValues is not null && restrictionValues.Length > 0)
798798
throw new ArgumentException("restrictionValues is not supported for schema 'UserPrivileges'.", nameof(restrictionValues));
799799

800800
dataTable.TableName = tableName;
@@ -811,7 +811,7 @@ private async Task FillUserPrivilegesAsync(IOBehavior ioBehavior, DataTable data
811811

812812
private async Task FillViewsAsync(IOBehavior ioBehavior, DataTable dataTable, string tableName, string?[]? restrictionValues, CancellationToken cancellationToken)
813813
{
814-
if (restrictionValues is not null)
814+
if (restrictionValues is not null && restrictionValues.Length > 0)
815815
throw new ArgumentException("restrictionValues is not supported for schema 'Views'.", nameof(restrictionValues));
816816

817817
dataTable.TableName = tableName;

tools/SchemaCollectionGenerator/SchemaCollectionGenerator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public async ValueTask<DataTable> GetSchemaAsync(IOBehavior ioBehavior, string c
6262
if (!supportsRestrictions)
6363
{
6464
codeWriter.WriteLine($"""
65-
if (restrictionValues is not null)
65+
if (restrictionValues is not null && restrictionValues.Length > 0)
6666
throw new ArgumentException("restrictionValues is not supported for schema '{schema.Name}'.", nameof(restrictionValues));
6767
""");
6868
}

0 commit comments

Comments
 (0)