MCPcopy Create free account
hub / github.com/piccolo-orm/piccolo / test_any

Method test_any

tests/columns/test_array.py:91–114  ·  view source on GitHub ↗

Make sure rows can be retrieved where any items in an array match a given value.

(self)

Source from the content-addressed store, hash-verified

89
90 @engines_skip("sqlite")
91 def test_any(self):
92 """
93 Make sure rows can be retrieved where any items in an array match a
94 given value.
95 """
96 MyTable(value=[1, 2, 3]).save().run_sync()
97
98 # We have to explicitly specify the type, so CockroachDB works.
99 self.assertEqual(
100 MyTable.select(MyTable.value)
101 .where(MyTable.value.any(QueryString("{}::INTEGER", 1)))
102 .first()
103 .run_sync(),
104 {"value": [1, 2, 3]},
105 )
106
107 # We have to explicitly specify the type, so CockroachDB works.
108 self.assertEqual(
109 MyTable.select(MyTable.value)
110 .where(MyTable.value.any(QueryString("{}::INTEGER", 0)))
111 .first()
112 .run_sync(),
113 None,
114 )
115
116 @engines_skip("sqlite")
117 def test_not_any(self):

Callers

nothing calls this directly

Calls 9

QueryStringClass · 0.90
saveMethod · 0.80
assertEqualMethod · 0.80
selectMethod · 0.80
anyMethod · 0.80
MyTableClass · 0.70
run_syncMethod · 0.45
firstMethod · 0.45
whereMethod · 0.45

Tested by

no test coverage detected