MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_fk_w_no_colname

Method test_fk_w_no_colname

test/sql/test_metadata.py:1060–1079  ·  view source on GitHub ↗

test a ForeignKey that refers to table name only. the column name is assumed to be the same col name on parent table. this is a little used feature from long ago that nonetheless is still in the code. The feature was found to be not working but is repaired for

(self)

Source from the content-addressed store, hash-verified

1058 assert b2.c.y.references(a2.c.x)
1059
1060 def test_fk_w_no_colname(self):
1061 """test a ForeignKey that refers to table name only. the column
1062 name is assumed to be the same col name on parent table.
1063
1064 this is a little used feature from long ago that nonetheless is
1065 still in the code.
1066
1067 The feature was found to be not working but is repaired for
1068 SQLAlchemy 2.0.
1069
1070 """
1071 m1 = MetaData()
1072 a = Table("a", m1, Column("x", Integer))
1073 b = Table("b", m1, Column("x", Integer, ForeignKey("a")))
1074 assert b.c.x.references(a.c.x)
1075
1076 m2 = MetaData()
1077 b2 = b.to_metadata(m2)
1078 a2 = a.to_metadata(m2)
1079 assert b2.c.x.references(a2.c.x)
1080
1081 def test_fk_w_no_colname_name_missing(self):
1082 """test a ForeignKey that refers to table name only. the column

Callers

nothing calls this directly

Calls 6

to_metadataMethod · 0.95
MetaDataClass · 0.90
TableClass · 0.90
ColumnClass · 0.90
ForeignKeyClass · 0.90
referencesMethod · 0.45

Tested by

no test coverage detected