Skip to content

Commit

Permalink
Fix for issue #4168 (part 1)
Browse files Browse the repository at this point in the history
- Make TableSelectionSetExtension implementation case insensitive
- Fix R# warnings
- Update test to work with case-insensitive table name
  • Loading branch information
ErikEJ committed Dec 24, 2015
1 parent 586e552 commit bfc8da1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,33 +1,34 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
using System.Linq;
using JetBrains.Annotations;

namespace Microsoft.Data.Entity.Scaffolding
{
internal static class SqlServerTableSelectionSetExtensions
{
public static bool Allows(this TableSelectionSet _tableSelectionSet, [NotNull] string schemaName, [NotNull] string tableName)
public static bool Allows(this TableSelectionSet tableSelectionSet, [NotNull] string schemaName, [NotNull] string tableName)
{
if (_tableSelectionSet == null
|| (_tableSelectionSet.Schemas.Count == 0
&& _tableSelectionSet.Tables.Count == 0))
if ((tableSelectionSet == null)
|| ((tableSelectionSet.Schemas.Count == 0)
&& (tableSelectionSet.Tables.Count == 0)))
{
return true;
}

if (_tableSelectionSet.Schemas.Contains(schemaName))
if (tableSelectionSet.Schemas.Contains(schemaName))
{
return true;
}

return _tableSelectionSet.Tables.Contains($"{schemaName}.{tableName}")
|| _tableSelectionSet.Tables.Contains($"[{schemaName}].[{tableName}]")
|| _tableSelectionSet.Tables.Contains($"{schemaName}.[{tableName}]")
|| _tableSelectionSet.Tables.Contains($"[{schemaName}].{tableName}")
|| _tableSelectionSet.Tables.Contains($"{tableName}")
|| _tableSelectionSet.Tables.Contains($"[{tableName}]");
return tableSelectionSet.Tables.Contains($"{schemaName}.{tableName}", StringComparer.OrdinalIgnoreCase)
|| tableSelectionSet.Tables.Contains($"[{schemaName}].[{tableName}]", StringComparer.OrdinalIgnoreCase)
|| tableSelectionSet.Tables.Contains($"{schemaName}.[{tableName}]", StringComparer.OrdinalIgnoreCase)
|| tableSelectionSet.Tables.Contains($"[{schemaName}].{tableName}", StringComparer.OrdinalIgnoreCase)
|| tableSelectionSet.Tables.Contains($"{tableName}", StringComparer.OrdinalIgnoreCase)
|| tableSelectionSet.Tables.Contains($"[{tableName}]", StringComparer.OrdinalIgnoreCase);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ internal static class SqliteTableSelectionSetExtensions
{
public static bool Allows(this TableSelectionSet tableSet, string tableName)
{
if (tableSet == null
|| tableSet.Tables.Count == 0)
if ((tableSet == null)
|| (tableSet.Tables.Count == 0))
{
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public static TableSelectionSet Filter
"OneToOneFKToUniqueKeyPrincipal",
"ReferredToByTableWithUnmappablePrimaryKeyColumn",
"TableWithUnmappablePrimaryKeyColumn",
"SelfReferencing",
"selfreferencing",
});

public SqlServerE2ETests(SqlServerE2EFixture fixture, ITestOutputHelper output)
Expand Down

0 comments on commit bfc8da1

Please sign in to comment.