MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_pks_not_uniques

Method test_pks_not_uniques

test/engine/test_reflection.py:1066–1084  ·  view source on GitHub ↗

test that primary key reflection not tripped up by unique indexes

(self, connection, metadata)

Source from the content-addressed store, hash-verified

1064 eq_(getattr(fk, attr), getattr(ref, attr))
1065
1066 def test_pks_not_uniques(self, connection, metadata):
1067 """test that primary key reflection not tripped up by unique
1068 indexes"""
1069
1070 conn = connection
1071 conn.exec_driver_sql("""
1072 CREATE TABLE book (
1073 id INTEGER NOT NULL,
1074 title VARCHAR(100) NOT NULL,
1075 series INTEGER,
1076 series_id INTEGER,
1077 UNIQUE(series, series_id),
1078 PRIMARY KEY(id)
1079 )""")
1080
1081 book = Table("book", metadata, autoload_with=connection)
1082 assert book.primary_key.contains_column(book.c.id)
1083 assert not book.primary_key.contains_column(book.c.series)
1084 eq_(len(book.primary_key), 1)
1085
1086 def test_fk_error(self, connection, metadata):
1087 Table(

Callers

nothing calls this directly

Calls 4

TableClass · 0.90
eq_Function · 0.90
exec_driver_sqlMethod · 0.45
contains_columnMethod · 0.45

Tested by

no test coverage detected