diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2008-01-11 21:24:01 +0000 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2008-01-11 21:24:01 +0000 |
| commit | 6d2d5e923ee32eeea3918d2672f54dff253b253f (patch) | |
| tree | 8871b7058759a2cf60a88c4e07cc70d806c2f9be /lib/sqlalchemy | |
| parent | 664ba4467901df344e915cb50663548c74a703c6 (diff) | |
| download | sqlalchemy-6d2d5e923ee32eeea3918d2672f54dff253b253f.tar.gz | |
- added "ilike()" operator to column operations.
compiles to ILIKE on postgres, lower(x) LIKE lower(y)
on all others [ticket:727]
Diffstat (limited to 'lib/sqlalchemy')
| -rw-r--r-- | lib/sqlalchemy/databases/postgres.py | 3 | ||||
| -rw-r--r-- | lib/sqlalchemy/sql/compiler.py | 2 | ||||
| -rw-r--r-- | lib/sqlalchemy/sql/expression.py | 4 |
3 files changed, 7 insertions, 2 deletions
diff --git a/lib/sqlalchemy/databases/postgres.py b/lib/sqlalchemy/databases/postgres.py index 19db8b6b7..bab998d69 100644 --- a/lib/sqlalchemy/databases/postgres.py +++ b/lib/sqlalchemy/databases/postgres.py @@ -625,7 +625,8 @@ class PGCompiler(compiler.DefaultCompiler): operators = compiler.DefaultCompiler.operators.copy() operators.update( { - sql_operators.mod : '%%' + sql_operators.mod : '%%', + sql_operators.ilike_op: 'ILIKE' } ) diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py index 35a12efe3..545c0a1b4 100644 --- a/lib/sqlalchemy/sql/compiler.py +++ b/lib/sqlalchemy/sql/compiler.py @@ -79,7 +79,7 @@ OPERATORS = { operators.concat_op : '||', operators.like_op : 'LIKE', operators.notlike_op : 'NOT LIKE', - operators.ilike_op : 'ILIKE', + operators.ilike_op : lambda x, y: "lower(%s) LIKE lower(%s)" % (x, y), operators.notilike_op : 'NOT ILIKE', operators.between_op : 'BETWEEN', operators.in_op : 'IN', diff --git a/lib/sqlalchemy/sql/expression.py b/lib/sqlalchemy/sql/expression.py index 0bf9bea10..187b38a2c 100644 --- a/lib/sqlalchemy/sql/expression.py +++ b/lib/sqlalchemy/sql/expression.py @@ -1113,6 +1113,9 @@ class ColumnOperators(Operators): def like(self, other): return self.operate(operators.like_op, other) + def ilike(self, other): + return self.operate(operators.ilike_op, other) + def in_(self, *other): return self.operate(operators.in_op, other) @@ -1205,6 +1208,7 @@ class _CompareMixin(ColumnOperators): operators.ge : (__compare, operators.lt), operators.eq : (__compare, operators.ne), operators.like_op : (__compare, operators.notlike_op), + operators.ilike_op : (__compare, operators.notilike_op), } def operate(self, op, *other): |
