MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / iendswith

Method iendswith

lib/sqlalchemy/sql/operators.py:1536–1621  ·  view source on GitHub ↗

r"""Implement the ``iendswith`` operator, e.g. case insensitive version of :meth:`.ColumnOperators.endswith`. Produces a LIKE expression that tests against an insensitive match for the end of a string value: .. sourcecode:: sql lower(column) LIKE '%' ||

(
        self,
        other: Any,
        escape: Optional[str] = None,
        autoescape: bool = False,
    )

Source from the content-addressed store, hash-verified

1534 )
1535
1536 def iendswith(
1537 self,
1538 other: Any,
1539 escape: Optional[str] = None,
1540 autoescape: bool = False,
1541 ) -> ColumnOperators:
1542 r"""Implement the ``iendswith`` operator, e.g. case insensitive
1543 version of :meth:`.ColumnOperators.endswith`.
1544
1545 Produces a LIKE expression that tests against an insensitive match
1546 for the end of a string value:
1547
1548 .. sourcecode:: sql
1549
1550 lower(column) LIKE '%' || lower(<other>)
1551
1552 E.g.::
1553
1554 stmt = select(sometable).where(sometable.c.column.iendswith("foobar"))
1555
1556 Since the operator uses ``LIKE``, wildcard characters
1557 ``"%"`` and ``"_"`` that are present inside the <other> expression
1558 will behave like wildcards as well. For literal string
1559 values, the :paramref:`.ColumnOperators.iendswith.autoescape` flag
1560 may be set to ``True`` to apply escaping to occurrences of these
1561 characters within the string value so that they match as themselves
1562 and not as wildcard characters. Alternatively, the
1563 :paramref:`.ColumnOperators.iendswith.escape` parameter will establish
1564 a given character as an escape character which can be of use when
1565 the target expression is not a literal string.
1566
1567 :param other: expression to be compared. This is usually a plain
1568 string value, but can also be an arbitrary SQL expression. LIKE
1569 wildcard characters ``%`` and ``_`` are not escaped by default unless
1570 the :paramref:`.ColumnOperators.iendswith.autoescape` flag is
1571 set to True.
1572
1573 :param autoescape: boolean; when True, establishes an escape character
1574 within the LIKE expression, then applies it to all occurrences of
1575 ``"%"``, ``"_"`` and the escape character itself within the
1576 comparison value, which is assumed to be a literal string and not a
1577 SQL expression.
1578
1579 An expression such as::
1580
1581 somecolumn.iendswith("foo%bar", autoescape=True)
1582
1583 Will render as:
1584
1585 .. sourcecode:: sql
1586
1587 lower(somecolumn) LIKE '%' || lower(:param) ESCAPE '/'
1588
1589 With the value of ``:param`` as ``"foo/%bar"``.
1590
1591 :param escape: a character which when given will render with the
1592 ``ESCAPE`` keyword to establish that character as the escape
1593 character. This character can then be placed preceding occurrences

Calls 1

operateMethod · 0.95