Skip to content

Commit 40a942f

Browse files
authored
refactor: Dedup tables only at the top level in FlattenTables (#1107)
Noticed this while working on #1106. Don't think we need to dedup at each level of the recursion. Also not sure why we're deduping as table names should be unique ---
1 parent d563582 commit 40a942f

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

schema/table.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,15 +254,21 @@ func (tt Tables) FilterDfs(tables, skipTables []string, skipDependentTables bool
254254
return tt.FilterDfsFunc(include, exclude, skipDependentTables), nil
255255
}
256256

257-
func (tt Tables) FlattenTables() Tables {
257+
func (tt Tables) flattenTablesRecursive() Tables {
258258
tables := make(Tables, 0, len(tt))
259259
for _, t := range tt {
260260
table := *t
261261
table.Relations = nil
262262
tables = append(tables, &table)
263-
tables = append(tables, t.Relations.FlattenTables()...)
263+
tables = append(tables, t.Relations.flattenTablesRecursive()...)
264264
}
265265

266+
return tables
267+
}
268+
269+
func (tt Tables) FlattenTables() Tables {
270+
tables := tt.flattenTablesRecursive()
271+
266272
seen := make(map[string]struct{})
267273
deduped := make(Tables, 0, len(tables))
268274
for _, t := range tables {

0 commit comments

Comments
 (0)