Skip to content

Commit ba0f2d6

Browse files
committed
Fix selecting referenced table for constraints (#1055).
1 parent e365ba3 commit ba0f2d6

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

src/FirebirdSql.EntityFrameworkCore.Firebird/Scaffolding/Internal/FbDatabaseModelFactory.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,10 @@ public override DatabaseModel Create(DbConnection connection, DatabaseModelFacto
6868
foreach (var table in tables)
6969
{
7070
table.Database = databaseModel;
71-
databaseModel.Tables.Add(table);
71+
if (tableFilter.Invoke(table))
72+
{
73+
databaseModel.Tables.Add(table);
74+
}
7275
}
7376

7477
return databaseModel;
@@ -87,9 +90,9 @@ private static string GetDefaultSchema(DbConnection connection)
8790
return null;
8891
}
8992

90-
private static Func<string, string, bool> GenerateTableFilter(IReadOnlyList<string> tables, IReadOnlyList<string> schemas)
93+
private static Func<DatabaseTable, bool> GenerateTableFilter(IReadOnlyList<string> tables, IReadOnlyList<string> schemas)
9194
{
92-
return tables.Any() ? (s, t) => tables.Contains(t) : null;
95+
return tables.Any() ? x => tables.Contains(x.Name) : _ => true;
9396
}
9497

9598
private const string GetTablesQuery =
@@ -104,7 +107,7 @@ private static Func<string, string, bool> GenerateTableFilter(IReadOnlyList<stri
104107
ORDER BY
105108
r.RDB$RELATION_NAME";
106109

107-
private IEnumerable<DatabaseTable> GetTables(DbConnection connection, Func<string, string, bool> filter)
110+
private IEnumerable<DatabaseTable> GetTables(DbConnection connection, Func<DatabaseTable, bool> filter)
108111
{
109112
using (var command = connection.CreateCommand())
110113
{
@@ -126,10 +129,7 @@ private IEnumerable<DatabaseTable> GetTables(DbConnection connection, Func<strin
126129
table.Name = name;
127130
table.Comment = string.IsNullOrEmpty(comment) ? null : comment;
128131

129-
if (filter?.Invoke(table.Schema, table.Name) ?? true)
130-
{
131-
tables.Add(table);
132-
}
132+
tables.Add(table);
133133
}
134134
}
135135

@@ -195,7 +195,7 @@ AND COALESCE(RF.RDB$SYSTEM_FLAG, 0) = 0
195195
ORDER BY
196196
RF.RDB$FIELD_POSITION;";
197197

198-
private void GetColumns(DbConnection connection, IReadOnlyList<DatabaseTable> tables, Func<string, string, bool> tableFilter)
198+
private void GetColumns(DbConnection connection, IReadOnlyList<DatabaseTable> tables, Func<DatabaseTable, bool> tableFilter)
199199
{
200200
var identityType = MajorVersionNumber < 3 ? "null" : "rf.RDB$IDENTITY_TYPE";
201201

@@ -318,7 +318,7 @@ GROUP BY
318318
/// <remarks>
319319
/// Primary keys are handled as in <see cref="GetConstraints"/>, not here
320320
/// </remarks>
321-
private void GetIndexes(DbConnection connection, IReadOnlyList<DatabaseTable> tables, Func<string, string, bool> tableFilter)
321+
private void GetIndexes(DbConnection connection, IReadOnlyList<DatabaseTable> tables, Func<DatabaseTable, bool> tableFilter)
322322
{
323323
foreach (var table in tables)
324324
{

0 commit comments

Comments
 (0)