MCPcopy Create free account
hub / github.com/tortoise/tortoise-orm / test_array_length

Function test_array_length

tests/fields/test_array.py:180–193  ·  view source on GitHub ↗

Test array length filter.

(db_array_fields)

Source from the content-addressed store, hash-verified

178@requireCapability(dialect="postgres")
179@pytest.mark.asyncio
180async def test_array_length(db_array_fields):
181 """Test array length filter."""
182 await testmodels.ArrayFields.create(array=[1, 2, 3])
183 await testmodels.ArrayFields.create(array=[1])
184 await testmodels.ArrayFields.create(array=[1, 2])
185
186 found = await testmodels.ArrayFields.filter(array__len=3).values_list("array", flat=True)
187 assert list(found) == [[1, 2, 3]]
188
189 found = await testmodels.ArrayFields.filter(array__len=1).values_list("array", flat=True)
190 assert list(found) == [[1]]
191
192 found = await testmodels.ArrayFields.filter(array__len=0).values_list("array", flat=True)
193 assert list(found) == []

Callers

nothing calls this directly

Calls 3

createMethod · 0.45
values_listMethod · 0.45
filterMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…