MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / AnyAllTest

Class AnyAllTest

test/sql/test_operators.py:4997–5218  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4995
4996
4997class AnyAllTest(fixtures.TestBase, testing.AssertsCompiledSQL):
4998 __dialect__ = "default"
4999
5000 @testing.fixture
5001 def t_fixture(self):
5002 m = MetaData()
5003
5004 t = Table(
5005 "tab1",
5006 m,
5007 Column("arrval", ARRAY(Integer)),
5008 Column("arrenum", ARRAY(Enum(MyEnum))),
5009 Column("arrstring", ARRAY(String)),
5010 Column("data", Integer),
5011 )
5012 return t
5013
5014 null_comparisons = testing.combinations(
5015 lambda col: any_(col) == None,
5016 lambda col: col.any_() == None,
5017 lambda col: any_(col) == null(),
5018 lambda col: col.any_() == null(),
5019 lambda col: null() == any_(col),
5020 lambda col: null() == col.any_(),
5021 lambda col: None == any_(col),
5022 lambda col: None == col.any_(),
5023 argnames="expr",
5024 )
5025
5026 @null_comparisons
5027 @testing.combinations("int", "array", argnames="datatype")
5028 def test_any_generic_null(self, datatype, expr, t_fixture):
5029 col = t_fixture.c.data if datatype == "int" else t_fixture.c.arrval
5030
5031 self.assert_compile(expr(col), "NULL = ANY (tab1.%s)" % col.name)
5032
5033 @null_comparisons
5034 @testing.combinations("int", "array", argnames="datatype")
5035 def test_any_generic_null_negate(self, datatype, expr, t_fixture):
5036 col = t_fixture.c.data if datatype == "int" else t_fixture.c.arrval
5037
5038 self.assert_compile(
5039 ~expr(col), "NOT (NULL = ANY (tab1.%s))" % col.name
5040 )
5041
5042 @testing.variation("operator", ["any", "all"])
5043 @testing.variation(
5044 "datatype", ["int", "array", "arraystring", "arrayenum"]
5045 )
5046 def test_what_type_is_any_all(
5047 self,
5048 datatype: testing.Variation,
5049 t_fixture,
5050 operator: testing.Variation,
5051 ):
5052 """test for #12874"""
5053
5054 if datatype.int:

Callers

nothing calls this directly

Calls 4

any_Class · 0.90
nullFunction · 0.90
combinationsMethod · 0.45
any_Method · 0.45

Tested by

no test coverage detected