MCPcopy
hub / github.com/ormar-orm/ormar / exists

Method exists

ormar/queryset/queryset.py:763–775  ·  view source on GitHub ↗

Returns a bool value to confirm if there are rows matching the given criteria (applied with `filter` and `exclude` if set). :return: result of the check :rtype: bool

(self)

Source from the content-addressed store, hash-verified

761 )
762
763 async def exists(self) -> bool:
764 """
765 Returns a bool value to confirm if there are rows matching the given criteria
766 (applied with `filter` and `exclude` if set).
767
768 :return: result of the check
769 :rtype: bool
770 """
771 expr = self.build_select_expression()
772 expr = sqlalchemy.exists(expr).select()
773 async with self.model_config.database.get_query_executor() as executor:
774 result = await executor.fetch_val(expr)
775 return bool(result)
776
777 async def count(self, distinct: bool = True) -> int:
778 """

Callers 8

test_queryset_methodsFunction · 0.45
test_model_existsFunction · 0.45
test_selecting_relatedFunction · 0.45
test_selecting_relatedFunction · 0.45
test_selecting_relatedFunction · 0.45
aggregationsFunction · 0.45
check_existsFunction · 0.45

Calls 3

get_query_executorMethod · 0.80
fetch_valMethod · 0.80

Tested by 7

test_queryset_methodsFunction · 0.36
test_model_existsFunction · 0.36
test_selecting_relatedFunction · 0.36
test_selecting_relatedFunction · 0.36
test_selecting_relatedFunction · 0.36
check_existsFunction · 0.36