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

Method iendswith

lib/sqlalchemy/sql/operators.py:1346–1431  ·  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

1344 )
1345
1346 def iendswith(
1347 self,
1348 other: Any,
1349 escape: Optional[str] = None,
1350 autoescape: bool = False,
1351 ) -> ColumnOperators:
1352 r"""Implement the ``iendswith`` operator, e.g. case insensitive
1353 version of :meth:`.ColumnOperators.endswith`.
1354
1355 Produces a LIKE expression that tests against an insensitive match
1356 for the end of a string value:
1357
1358 .. sourcecode:: sql
1359
1360 lower(column) LIKE '%' || lower(<other>)
1361
1362 E.g.::
1363
1364 stmt = select(sometable).where(sometable.c.column.iendswith("foobar"))
1365
1366 Since the operator uses ``LIKE``, wildcard characters
1367 ``"%"`` and ``"_"`` that are present inside the <other> expression
1368 will behave like wildcards as well. For literal string
1369 values, the :paramref:`.ColumnOperators.iendswith.autoescape` flag
1370 may be set to ``True`` to apply escaping to occurrences of these
1371 characters within the string value so that they match as themselves
1372 and not as wildcard characters. Alternatively, the
1373 :paramref:`.ColumnOperators.iendswith.escape` parameter will establish
1374 a given character as an escape character which can be of use when
1375 the target expression is not a literal string.
1376
1377 :param other: expression to be compared. This is usually a plain
1378 string value, but can also be an arbitrary SQL expression. LIKE
1379 wildcard characters ``%`` and ``_`` are not escaped by default unless
1380 the :paramref:`.ColumnOperators.iendswith.autoescape` flag is
1381 set to True.
1382
1383 :param autoescape: boolean; when True, establishes an escape character
1384 within the LIKE expression, then applies it to all occurrences of
1385 ``"%"``, ``"_"`` and the escape character itself within the
1386 comparison value, which is assumed to be a literal string and not a
1387 SQL expression.
1388
1389 An expression such as::
1390
1391 somecolumn.iendswith("foo%bar", autoescape=True)
1392
1393 Will render as:
1394
1395 .. sourcecode:: sql
1396
1397 lower(somecolumn) LIKE '%' || lower(:param) ESCAPE '/'
1398
1399 With the value of ``:param`` as ``"foo/%bar"``.
1400
1401 :param escape: a character which when given will render with the
1402 ``ESCAPE`` keyword to establish that character as the escape
1403 character. This character can then be placed preceding occurrences

Calls 1

operateMethod · 0.95