r"""Apply the given filtering criterion as a WHERE clause to this DML statement, using keyword expressions. E.g.:: stmt = update(User).filter_by(name="some name").values(fullname="New Name") Multiple criteria may be specified as comma separated; the effect
(self, **kwargs: Any)
| 1563 | return self.where(*criteria) |
| 1564 | |
| 1565 | def filter_by(self, **kwargs: Any) -> Self: |
| 1566 | r"""Apply the given filtering criterion as a WHERE clause |
| 1567 | to this DML statement, using keyword expressions. |
| 1568 | |
| 1569 | E.g.:: |
| 1570 | |
| 1571 | stmt = update(User).filter_by(name="some name").values(fullname="New Name") |
| 1572 | |
| 1573 | Multiple criteria may be specified as comma separated; the effect |
| 1574 | is that they will be joined together using the :func:`.and_` |
| 1575 | function:: |
| 1576 | |
| 1577 | stmt = delete(User).filter_by(name="some name", id=5) |
| 1578 | |
| 1579 | The keyword expressions are extracted by searching across **all |
| 1580 | entities present in the FROM clause** of the statement. |
| 1581 | |
| 1582 | .. versionchanged:: 2.1 |
| 1583 | |
| 1584 | :meth:`.DMLWhereBase.filter_by` now searches across all FROM clause |
| 1585 | entities, consistent with :meth:`_sql.Select.filter_by`. |
| 1586 | |
| 1587 | .. seealso:: |
| 1588 | |
| 1589 | :meth:`.where` - filter on SQL expressions. |
| 1590 | |
| 1591 | :meth:`_sql.Select.filter_by` |
| 1592 | |
| 1593 | """ # noqa: E501 |
| 1594 | |
| 1595 | entities: set[Any] |
| 1596 | |
| 1597 | if not isinstance(self.table, TableClause): |
| 1598 | entities = set( |
| 1599 | sql_util.find_tables( |
| 1600 | self.table, check_columns=False, include_joins=False |
| 1601 | ) |
| 1602 | ) |
| 1603 | else: |
| 1604 | entities = {self.table} |
| 1605 | |
| 1606 | if self.whereclause is not None: |
| 1607 | entities.update(self.whereclause._from_objects) |
| 1608 | |
| 1609 | clauses = [ |
| 1610 | _entity_namespace_key_search_all(entities, key) == value |
| 1611 | for key, value in kwargs.items() |
| 1612 | ] |
| 1613 | return self.filter(*clauses) |
| 1614 | |
| 1615 | @property |
| 1616 | def whereclause(self) -> Optional[ColumnElement[Any]]: |
nothing calls this directly
no test coverage detected