Skip to content

Commit efe7f66

Browse files
authored
Merge pull request #143 from aokiji/fix/test_for_extract_tables_fail
fix: make order of extracTables deterministic
2 parents f88acb1 + 8a78c90 commit efe7f66

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

parser/parseutil/parseutil.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -244,14 +244,15 @@ func extractTables(parsed ast.TokenList, pos token.Pos, stopOnPos bool) ([]*Tabl
244244
}
245245

246246
tableMap := map[string]*TableInfo{}
247-
for _, table := range tables {
248-
tableMap[table.DatabaseSchema+"\t"+table.Name] = table
249-
}
250247
cleanTables := []*TableInfo{}
251-
for _, table := range tableMap {
252-
cleanTables = append(cleanTables, table)
253-
}
254248

249+
for _, table := range tables {
250+
tableKey := table.DatabaseSchema+"\t"+table.Name
251+
if _, ok := tableMap[tableKey]; !ok {
252+
tableMap[tableKey] = table
253+
cleanTables = append(cleanTables, table)
254+
}
255+
}
255256
return cleanTables, nil
256257
}
257258

0 commit comments

Comments
 (0)