Skip to content

Commit

Permalink
Support empty array as restrictionValues
Browse files Browse the repository at this point in the history
  • Loading branch information
Thorium committed Nov 15, 2023
1 parent d895afc commit e3a87ab
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 28 deletions.
54 changes: 27 additions & 27 deletions src/MySqlConnector/Core/SchemaProvider.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public async ValueTask<DataTable> GetSchemaAsync(IOBehavior ioBehavior, string c

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

dataTable.TableName = tableName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public async ValueTask<DataTable> GetSchemaAsync(IOBehavior ioBehavior, string c
if (!supportsRestrictions)
{
codeWriter.WriteLine($"""
if (restrictionValues is not null)
if (restrictionValues is not null && restrictionValues.Length > 0)
throw new ArgumentException("restrictionValues is not supported for schema '{schema.Name}'.", nameof(restrictionValues));
""");
}
Expand Down

0 comments on commit e3a87ab

Please sign in to comment.