Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optmize check for excluded tables in SQL Server Provider #72

Open
marcominerva opened this issue Sep 26, 2024 · 0 comments
Open

Optmize check for excluded tables in SQL Server Provider #72

marcominerva opened this issue Sep 26, 2024 · 0 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@marcominerva
Copy link
Owner

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.

@marcominerva marcominerva added enhancement New feature or request help wanted Extra attention is needed labels Sep 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant