summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql/expression.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2008-03-19 20:25:51 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2008-03-19 20:25:51 +0000
commit8d0c5672f06952382b4eedf78158a043b3529878 (patch)
tree39af04ae51edbe52cc73141de30febb028628c25 /lib/sqlalchemy/sql/expression.py
parent0cc04e6e1b70abc4817f275a898aa063da3de007 (diff)
downloadsqlalchemy-8d0c5672f06952382b4eedf78158a043b3529878.tar.gz
added escape kw arg to contains(), startswith(), endswith(), [ticket:791]
Diffstat (limited to 'lib/sqlalchemy/sql/expression.py')
-rw-r--r--lib/sqlalchemy/sql/expression.py24
1 files changed, 12 insertions, 12 deletions
diff --git a/lib/sqlalchemy/sql/expression.py b/lib/sqlalchemy/sql/expression.py
index 701987e20..0d10c844a 100644
--- a/lib/sqlalchemy/sql/expression.py
+++ b/lib/sqlalchemy/sql/expression.py
@@ -1146,14 +1146,14 @@ class ColumnOperators(Operators):
def in_(self, *other):
return self.operate(operators.in_op, other)
- def startswith(self, other):
- return self.operate(operators.startswith_op, other)
+ def startswith(self, other, **kwargs):
+ return self.operate(operators.startswith_op, other, **kwargs)
- def endswith(self, other):
- return self.operate(operators.endswith_op, other)
+ def endswith(self, other, **kwargs):
+ return self.operate(operators.endswith_op, other, **kwargs)
- def contains(self, other):
- return self.operate(operators.contains_op, other)
+ def contains(self, other, **kwargs):
+ return self.operate(operators.contains_op, other, **kwargs)
def desc(self):
return self.operate(operators.desc_op)
@@ -1283,21 +1283,21 @@ class _CompareMixin(ColumnOperators):
return self.__compare(op, ClauseList(*args).self_group(against=op), negate=negate_op)
- def startswith(self, other):
+ def startswith(self, other, escape=None):
"""Produce the clause ``LIKE '<other>%'``"""
# use __radd__ to force string concat behavior
- return self.__compare(operators.like_op, literal_column("'%'", type_=sqltypes.String).__radd__(self._check_literal(other)))
+ return self.__compare(operators.like_op, literal_column("'%'", type_=sqltypes.String).__radd__(self._check_literal(other)), escape=escape)
- def endswith(self, other):
+ def endswith(self, other, escape=None):
"""Produce the clause ``LIKE '%<other>'``"""
- return self.__compare(operators.like_op, literal_column("'%'", type_=sqltypes.String) + self._check_literal(other))
+ return self.__compare(operators.like_op, literal_column("'%'", type_=sqltypes.String) + self._check_literal(other), escape=escape)
- def contains(self, other):
+ def contains(self, other, escape=None):
"""Produce the clause ``LIKE '%<other>%'``"""
- return self.__compare(operators.like_op, literal_column("'%'", type_=sqltypes.String) + self._check_literal(other) + literal_column("'%'", type_=sqltypes.String))
+ return self.__compare(operators.like_op, literal_column("'%'", type_=sqltypes.String) + self._check_literal(other) + literal_column("'%'", type_=sqltypes.String), escape=escape)
def label(self, name):
"""Produce a column label, i.e. ``<columnname> AS <name>``.