MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_annotated_fn_criteria

Method test_annotated_fn_criteria

test/orm/test_lazy_relations.py:803–837  ·  view source on GitHub ↗

this test is a secondary test for the compilation of functions that are annotated.

(self, registry, connection)

Source from the content-addressed store, hash-verified

801
802 @testing.only_on("sqlite")
803 def test_annotated_fn_criteria(self, registry, connection):
804 """this test is a secondary test for the compilation of functions
805 that are annotated.
806
807 """
808
809 @registry.mapped
810 class A:
811 __tablename__ = "a"
812
813 id = Column(Integer, primary_key=True)
814 _date = Column(Date, default=func.current_date())
815 b_id = Column(Integer, ForeignKey("b.id"))
816 b = relationship("B")
817
818 @registry.mapped
819 class B:
820 __tablename__ = "b"
821
822 id = Column(Integer, primary_key=True)
823 a_s = relationship(
824 "A",
825 primaryjoin="and_(B.id == A.b_id, "
826 "A._date >= func.current_date())",
827 viewonly=True,
828 )
829
830 registry.metadata.create_all(connection)
831 with Session(connection) as sess:
832 b1 = B(id=1)
833 a1 = A(b=b1)
834 sess.add_all([a1, b1])
835 sess.commit()
836
837 is_(sess.get(B, 1).a_s[0], a1)
838
839 def test_uses_get_compatible_types(self):
840 """test the use_get optimization with compatible

Callers

nothing calls this directly

Calls 8

SessionClass · 0.90
is_Function · 0.90
create_allMethod · 0.80
BClass · 0.70
AClass · 0.70
add_allMethod · 0.45
commitMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected