Skip to content

Optmize check for excluded tables in SQL Server Provider #72

Open
@marcominerva

Description

@marcominerva

The code in SQL Server Provider that checks for excluded columns is "cumbersome":

static bool IsIncluded(ColumnEntity column, IEnumerable<string> excludedColumns)
{
// Checks if the column should be included or not, verifying if it is present in the list of excluded columns.
var isIncluded = excludedColumns.All(e =>
{
var parts = e.Split('.');
var schemaOrColumnName = parts.ElementAtOrDefault(0)?.Trim();
var tableName = parts.ElementAtOrDefault(1)?.Trim();
var columnName = parts.ElementAtOrDefault(2)?.Trim();
if (string.IsNullOrWhiteSpace(columnName))
{
// The columnName variable is null: it means that the excluded column has been specified without the full qualified name.
// In this case, the schemaOrColumnName variable contains the column name and it is a column that must be excluded from all tables.
var isExcluded = column.Column.Equals(schemaOrColumnName, StringComparison.OrdinalIgnoreCase);
return !isExcluded;
}
else
{
// The excluded column has been specified using the full qualified name.
var isExcluded = column.Schema.Equals(schemaOrColumnName, StringComparison.OrdinalIgnoreCase)
&& column.Table.Equals(tableName, StringComparison.OrdinalIgnoreCase)
&& column.Column.Equals(columnName, StringComparison.OrdinalIgnoreCase);
return !isExcluded;
}
});
return isIncluded;
}
}

On the other hand, the Postgres Provider uses a more compact solution.

We should verify whether we can follow a similar approach also for SQL Server.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions