| 116 | |
| 117 | |
| 118 | class Parent(VersionedStartEnd, Base): |
| 119 | __tablename__ = "parent" |
| 120 | id = Column(Integer, primary_key=True) |
| 121 | start = Column(DateTime, primary_key=True) |
| 122 | end = Column(DateTime, primary_key=True) |
| 123 | data = Column(String) |
| 124 | |
| 125 | child_n = Column(Integer) |
| 126 | |
| 127 | child = relationship( |
| 128 | "Child", |
| 129 | primaryjoin=("Child.id == foreign(Parent.child_n)"), |
| 130 | # note the primaryjoin can also be: |
| 131 | # |
| 132 | # "and_(Child.id == foreign(Parent.child_n), " |
| 133 | # "func.now().between(Child.start, Child.end))" |
| 134 | # |
| 135 | # however the before_compile() above will take care of this for us in |
| 136 | # all cases except for joinedload. You *can* use the above primaryjoin |
| 137 | # as well, it just means the criteria will be present twice for most |
| 138 | # parent->child load operations |
| 139 | # |
| 140 | uselist=False, |
| 141 | backref=backref("parent", uselist=False), |
| 142 | ) |
| 143 | |
| 144 | |
| 145 | class Child(VersionedStartEnd, Base): |
no test coverage detected