(self)
| 444 | pass |
| 445 | |
| 446 | def test_basic(self): |
| 447 | peoplesites, PersonSite, Person, people = ( |
| 448 | self.tables.peoplesites, |
| 449 | self.classes.PersonSite, |
| 450 | self.classes.Person, |
| 451 | self.tables.people, |
| 452 | ) |
| 453 | |
| 454 | self.mapper_registry.map_imperatively(PersonSite, peoplesites) |
| 455 | m2 = self.mapper_registry.map_imperatively( |
| 456 | Person, people, properties={"sites": relationship(PersonSite)} |
| 457 | ) |
| 458 | |
| 459 | sa.orm.configure_mappers() |
| 460 | eq_( |
| 461 | list(m2.get_property("sites").synchronize_pairs), |
| 462 | [(people.c.person, peoplesites.c.person)], |
| 463 | ) |
| 464 | |
| 465 | p = Person(person="im the key", firstname="asdf") |
| 466 | ps = PersonSite(site="asdf") |
| 467 | p.sites.append(ps) |
| 468 | |
| 469 | session = fixture_session() |
| 470 | session.add(p) |
| 471 | session.flush() |
| 472 | |
| 473 | conn = session.connection() |
| 474 | p_count = conn.scalar( |
| 475 | select(func.count("*")).where(people.c.person == "im the key") |
| 476 | ) |
| 477 | eq_(p_count, 1) |
| 478 | eq_( |
| 479 | conn.scalar( |
| 480 | select(func.count("*")).where( |
| 481 | peoplesites.c.person == "im the key" |
| 482 | ) |
| 483 | ), |
| 484 | 1, |
| 485 | ) |
| 486 | |
| 487 | |
| 488 | class ClauseAttributesTest(fixtures.MappedTest): |
nothing calls this directly
no test coverage detected