MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / Parent

Class Parent

examples/versioned_rows/versioned_update_old_row.py:118–142  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

116
117
118class 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
145class Child(VersionedStartEnd, Base):

Callers 1

Calls 3

ColumnClass · 0.90
relationshipFunction · 0.90
backrefFunction · 0.90

Tested by

no test coverage detected