MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_composite_pks

Method test_composite_pks

test/engine/test_reflection.py:1104–1122  ·  view source on GitHub ↗

test reflection of a composite primary key

(self, connection, metadata)

Source from the content-addressed store, hash-verified

1102 )
1103
1104 def test_composite_pks(self, connection, metadata):
1105 """test reflection of a composite primary key"""
1106
1107 conn = connection
1108 conn.exec_driver_sql("""
1109 CREATE TABLE book (
1110 id INTEGER NOT NULL,
1111 isbn VARCHAR(50) NOT NULL,
1112 title VARCHAR(100) NOT NULL,
1113 series INTEGER NOT NULL,
1114 series_id INTEGER NOT NULL,
1115 UNIQUE(series, series_id),
1116 PRIMARY KEY(id, isbn)
1117 )""")
1118 book = Table("book", metadata, autoload_with=connection)
1119 assert book.primary_key.contains_column(book.c.id)
1120 assert book.primary_key.contains_column(book.c.isbn)
1121 assert not book.primary_key.contains_column(book.c.series)
1122 eq_(len(book.primary_key), 2)
1123
1124 def test_composite_fk(self, connection, metadata):
1125 """test reflection of composite foreign keys"""

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