Skip to content

Commit

Permalink
Fix NewSpannerLoaderFromDDL to check if table exists (#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
0g3 authored Jul 22, 2021
1 parent 41f9497 commit 072917f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion loaders/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ func NewSpannerLoaderFromDDL(fpath string) (*SpannerLoaderFromDDL, error) {
v.createTable = val
tables[val.Name.Name] = v
case *ast.CreateIndex:
v := tables[val.TableName.Name]
v, ok := tables[val.TableName.Name]
if !ok {
return nil, fmt.Errorf("table '%s' is undefined, but got '%s'", val.TableName.Name, ddl.SQL())
}
v.createIndexes = append(v.createIndexes, val)
tables[val.TableName.Name] = v
case *ast.AlterTable:
Expand Down

0 comments on commit 072917f

Please sign in to comment.