A server-side default can be used as the target of a foreign key
(self)
| 1280 | eq_(h1.foober, "im the update") |
| 1281 | |
| 1282 | def test_used_in_relationship(self): |
| 1283 | """A server-side default can be used as the target of a foreign key""" |
| 1284 | |
| 1285 | Hoho, hohoval, default_t, secondary_table, Secondary = ( |
| 1286 | self.classes.Hoho, |
| 1287 | self.other.hohoval, |
| 1288 | self.tables.default_t, |
| 1289 | self.tables.secondary_table, |
| 1290 | self.classes.Secondary, |
| 1291 | ) |
| 1292 | |
| 1293 | self.mapper_registry.map_imperatively( |
| 1294 | Hoho, |
| 1295 | default_t, |
| 1296 | properties={ |
| 1297 | "secondaries": relationship( |
| 1298 | Secondary, order_by=secondary_table.c.id |
| 1299 | ) |
| 1300 | }, |
| 1301 | ) |
| 1302 | self.mapper_registry.map_imperatively(Secondary, secondary_table) |
| 1303 | |
| 1304 | h1 = Hoho() |
| 1305 | s1 = Secondary(data="s1") |
| 1306 | h1.secondaries.append(s1) |
| 1307 | |
| 1308 | session = fixture_session() |
| 1309 | session.add(h1) |
| 1310 | session.flush() |
| 1311 | session.expunge_all() |
| 1312 | |
| 1313 | eq_( |
| 1314 | session.get(Hoho, h1.id), |
| 1315 | Hoho(hoho=hohoval, secondaries=[Secondary(data="s1")]), |
| 1316 | ) |
| 1317 | |
| 1318 | h1 = session.get(Hoho, h1.id) |
| 1319 | h1.secondaries.append(Secondary(data="s2")) |
| 1320 | session.flush() |
| 1321 | session.expunge_all() |
| 1322 | |
| 1323 | eq_( |
| 1324 | session.get(Hoho, h1.id), |
| 1325 | Hoho( |
| 1326 | hoho=hohoval, |
| 1327 | secondaries=[Secondary(data="s1"), Secondary(data="s2")], |
| 1328 | ), |
| 1329 | ) |
| 1330 | |
| 1331 | |
| 1332 | class ColumnPropertyTest(fixtures.MappedTest): |
nothing calls this directly
no test coverage detected