test reflection of composite foreign keys
(self, connection, metadata)
| 1122 | eq_(len(book.primary_key), 2) |
| 1123 | |
| 1124 | def test_composite_fk(self, connection, metadata): |
| 1125 | """test reflection of composite foreign keys""" |
| 1126 | |
| 1127 | meta = metadata |
| 1128 | multi = Table( |
| 1129 | "multi", |
| 1130 | meta, |
| 1131 | Column("multi_id", sa.Integer, primary_key=True), |
| 1132 | Column("multi_rev", sa.Integer, primary_key=True), |
| 1133 | Column("multi_hoho", sa.Integer, primary_key=True), |
| 1134 | Column("name", sa.String(50), nullable=False), |
| 1135 | Column("val", sa.String(100)), |
| 1136 | test_needs_fk=True, |
| 1137 | ) |
| 1138 | multi2 = Table( |
| 1139 | "multi2", |
| 1140 | meta, |
| 1141 | Column("id", sa.Integer, primary_key=True), |
| 1142 | Column("foo", sa.Integer), |
| 1143 | Column("bar", sa.Integer), |
| 1144 | Column("lala", sa.Integer), |
| 1145 | Column("data", sa.String(50)), |
| 1146 | sa.ForeignKeyConstraint( |
| 1147 | ["foo", "bar", "lala"], |
| 1148 | ["multi.multi_id", "multi.multi_rev", "multi.multi_hoho"], |
| 1149 | ), |
| 1150 | test_needs_fk=True, |
| 1151 | ) |
| 1152 | meta.create_all(connection) |
| 1153 | |
| 1154 | meta2 = MetaData() |
| 1155 | table = Table("multi", meta2, autoload_with=connection) |
| 1156 | table2 = Table("multi2", meta2, autoload_with=connection) |
| 1157 | self.assert_tables_equal(multi, table) |
| 1158 | self.assert_tables_equal(multi2, table2) |
| 1159 | j = sa.join(table, table2) |
| 1160 | |
| 1161 | self.assert_( |
| 1162 | sa.and_( |
| 1163 | table.c.multi_id == table2.c.foo, |
| 1164 | table.c.multi_rev == table2.c.bar, |
| 1165 | table.c.multi_hoho == table2.c.lala, |
| 1166 | ).compare(j.onclause) |
| 1167 | ) |
| 1168 | |
| 1169 | @testing.crashes("oracle", "FIXME: unknown, confirm not fails_on") |
| 1170 | @testing.requires.check_constraints |
nothing calls this directly
no test coverage detected