MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / filter

Method filter

lib/sqlalchemy/orm/query.py:1898–1930  ·  view source on GitHub ↗

r"""Apply the given filtering criterion to a copy of this :class:`_query.Query`, using SQL expressions. e.g.:: session.query(MyClass).filter(MyClass.name == "some name") Multiple criteria may be specified as comma separated; the effect is that they will

(self, *criterion: _ColumnExpressionArgument[bool])

Source from the content-addressed store, hash-verified

1896 @_generative
1897 @_assertions(_no_statement_condition, _no_limit_offset)
1898 def filter(self, *criterion: _ColumnExpressionArgument[bool]) -> Self:
1899 r"""Apply the given filtering criterion to a copy
1900 of this :class:`_query.Query`, using SQL expressions.
1901
1902 e.g.::
1903
1904 session.query(MyClass).filter(MyClass.name == "some name")
1905
1906 Multiple criteria may be specified as comma separated; the effect
1907 is that they will be joined together using the :func:`.and_`
1908 function::
1909
1910 session.query(MyClass).filter(MyClass.name == "some name", MyClass.id > 5)
1911
1912 The criterion is any SQL expression object applicable to the
1913 WHERE clause of a select. String expressions are coerced
1914 into SQL expression constructs via the :func:`_expression.text`
1915 construct.
1916
1917 .. seealso::
1918
1919 :meth:`_query.Query.filter_by` - filter on keyword expressions.
1920
1921 :meth:`_sql.Select.where` - v2 equivalent method.
1922
1923 """ # noqa: E501
1924 for crit in list(criterion):
1925 crit = coercions.expect(
1926 roles.WhereHavingRole, crit, apply_propagate_attrs=self
1927 )
1928
1929 self._where_criteria += (crit,)
1930 return self
1931
1932 @util.memoized_property
1933 def _last_joined_entity(

Callers 15

with_parentMethod · 0.95
whereMethod · 0.95
filter_byMethod · 0.95
_load_for_pathMethod · 0.45
CoreFixturesClass · 0.45
test_funcfilter_emptyMethod · 0.45
test_funcfilter_labelMethod · 0.45

Calls

no outgoing calls