@@ -209,7 +209,11 @@ func getForeignKeyEditor(ctx *sql.Context, a *Analyzer, tbl sql.ForeignKeyTable,
209209 if err != nil {
210210 return nil , err
211211 }
212- return getForeignKeyRefActions (ctx , a , tbl , cache , fkChain , fkEditor , checkRows )
212+ fkEditor , err = getForeignKeyRefActions (ctx , a , tbl , cache , fkChain , fkEditor , checkRows )
213+ if err != nil {
214+ return nil , err
215+ }
216+ return fkEditor , err
213217}
214218
215219// getForeignKeyReferences returns an editor containing only the references for the given table.
@@ -238,7 +242,7 @@ func getForeignKeyReferences(ctx *sql.Context, a *Analyzer, tbl sql.ForeignKeyTa
238242 if err != nil {
239243 return nil , err
240244 }
241- fkChain = fkChain .AddTable ( fks [ 0 ]. ParentDatabase , fks [ 0 ]. ParentTable ). AddTableUpdater (fks [0 ].ParentDatabase , fks [0 ].ParentTable , updater )
245+ fkChain = fkChain .AddTableUpdater (fks [0 ].Database , fks [0 ].Table , updater )
242246
243247 tblSch := tbl .Schema ()
244248 fkEditor := & plan.ForeignKeyEditor {
@@ -383,7 +387,8 @@ func getForeignKeyRefActions(ctx *sql.Context, a *Analyzer, tbl sql.ForeignKeyTa
383387 return nil , err
384388 }
385389
386- childEditor , err := getForeignKeyEditor (ctx , a , childTbl , cache , fkChain .AddForeignKey (fk .Name ), checkRows )
390+ fkChain = fkChain .AddForeignKey (fk .Name )
391+ childEditor , err := getForeignKeyEditor (ctx , a , childTbl , cache , fkChain , checkRows )
387392 if err != nil {
388393 return nil , err
389394 }
@@ -541,7 +546,7 @@ func (cache *foreignKeyCache) GetEditor(fkEditor *plan.ForeignKeyEditor, dbName
541546type foreignKeyChain struct {
542547 fkNames map [string ]struct {}
543548 fkTables map [foreignKeyTableName ]struct {}
544- fkUpdate map [foreignKeyTableName ]sql.ForeignKeyEditor
549+ fkUpdate map [foreignKeyTableName ]sql.ForeignKeyEditor // TODO: why is this even a map?
545550}
546551
547552// AddTable returns a new chain with the added table.
0 commit comments