Skip to content

Commit

Permalink
Fix foreign key reflection when there are tables with the same name i…
Browse files Browse the repository at this point in the history
…n different schemas (ibmdb#128)

Signed-off-by: Xnot <[email protected]>
  • Loading branch information
Xnot authored May 22, 2023
1 parent 9461229 commit c9195b4
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion ibm_db_sa/reflection.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,13 @@ def get_foreign_keys(self, connection, table_name, schema=None, **kw):
sysfkeys.c.pkname, sysfkeys.c.pktabschema,
sysfkeys.c.pktabname, sysfkeys.c.pkcolname).\
select_from(
join(systbl,sysfkeys, systbl.c.tabname == sysfkeys.c.pktabname)
join(systbl,
sysfkeys,
sql.and_(
systbl.c.tabname == sysfkeys.c.pktabname,
systbl.c.tabschema == sysfkeys.c.pktabschema
)
)
).where(systbl.c.type == 'T').\
where(systbl.c.tabschema == current_schema).\
where(sysfkeys.c.fktabname == table_name).\
Expand Down

0 comments on commit c9195b4

Please sign in to comment.