MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / AnyAllTest

Class AnyAllTest

test/sql/test_operators.py:4663–4963  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4661
4662
4663class AnyAllTest(fixtures.TestBase, testing.AssertsCompiledSQL):
4664 __dialect__ = "default"
4665
4666 @testing.fixture
4667 def t_fixture(self):
4668 m = MetaData()
4669
4670 t = Table(
4671 "tab1",
4672 m,
4673 Column("arrval", ARRAY(Integer)),
4674 Column("arrenum", ARRAY(Enum(MyEnum))),
4675 Column("arrstring", ARRAY(String)),
4676 Column("data", Integer),
4677 )
4678 return t
4679
4680 null_comparisons = testing.combinations(
4681 lambda col: any_(col) == None,
4682 lambda col: col.any_() == None,
4683 lambda col: any_(col) == null(),
4684 lambda col: col.any_() == null(),
4685 lambda col: null() == any_(col),
4686 lambda col: null() == col.any_(),
4687 lambda col: None == any_(col),
4688 lambda col: None == col.any_(),
4689 argnames="expr",
4690 )
4691
4692 @null_comparisons
4693 @testing.combinations("int", "array", argnames="datatype")
4694 def test_any_generic_null(self, datatype, expr, t_fixture):
4695 col = t_fixture.c.data if datatype == "int" else t_fixture.c.arrval
4696
4697 self.assert_compile(expr(col), "NULL = ANY (tab1.%s)" % col.name)
4698
4699 @null_comparisons
4700 @testing.combinations("int", "array", argnames="datatype")
4701 def test_any_generic_null_negate(self, datatype, expr, t_fixture):
4702 col = t_fixture.c.data if datatype == "int" else t_fixture.c.arrval
4703
4704 self.assert_compile(
4705 ~expr(col), "NOT (NULL = ANY (tab1.%s))" % col.name
4706 )
4707
4708 @testing.variation("operator", ["any", "all"])
4709 @testing.variation(
4710 "datatype", ["int", "array", "arraystring", "arrayenum"]
4711 )
4712 def test_what_type_is_any_all(
4713 self,
4714 datatype: testing.Variation,
4715 t_fixture,
4716 operator: testing.Variation,
4717 ):
4718 """test for #12874"""
4719
4720 if datatype.int:

Callers

nothing calls this directly

Calls 4

any_Function · 0.90
nullFunction · 0.90
combinationsMethod · 0.45
any_Method · 0.45

Tested by

no test coverage detected