diff options
author | Michael Trier <mtrier@gmail.com> | 2008-07-13 04:45:37 +0000 |
---|---|---|
committer | Michael Trier <mtrier@gmail.com> | 2008-07-13 04:45:37 +0000 |
commit | f899157ca9f6f5104a358420eba8f1b9019ece6f (patch) | |
tree | 37baa09bec04f9c1f93fa4ea4a798158cc3c75e1 /lib/sqlalchemy/databases | |
parent | bad78d9767fb9b076c7a6388286a0c37a81d8bc5 (diff) | |
download | sqlalchemy-f899157ca9f6f5104a358420eba8f1b9019ece6f.tar.gz |
Added new basic match() operator that performs a full-text search. Supported on PostgreSQL, SQLite, MySQL, MS-SQL, and Oracle backends.
Diffstat (limited to 'lib/sqlalchemy/databases')
-rw-r--r-- | lib/sqlalchemy/databases/mssql.py | 6 | ||||
-rw-r--r-- | lib/sqlalchemy/databases/mysql.py | 3 | ||||
-rw-r--r-- | lib/sqlalchemy/databases/oracle.py | 3 | ||||
-rw-r--r-- | lib/sqlalchemy/databases/postgres.py | 1 |
4 files changed, 10 insertions, 3 deletions
diff --git a/lib/sqlalchemy/databases/mssql.py b/lib/sqlalchemy/databases/mssql.py index 112c8ead4..03de7290e 100644 --- a/lib/sqlalchemy/databases/mssql.py +++ b/lib/sqlalchemy/databases/mssql.py @@ -41,6 +41,7 @@ import datetime, operator, re, sys from sqlalchemy import sql, schema, exc, util from sqlalchemy.sql import compiler, expression, operators as sqlops, functions as sql_functions +from sqlalchemy.sql import compiler, expression, operators as sql_operators, functions as sql_functions from sqlalchemy.engine import default, base from sqlalchemy import types as sqltypes from sqlalchemy.util import Decimal as _python_Decimal @@ -867,7 +868,10 @@ dialect_mapping = { class MSSQLCompiler(compiler.DefaultCompiler): operators = compiler.OPERATORS.copy() - operators[sqlops.concat_op] = '+' + operators.update({ + sql_operators.concat_op: '+', + sql_operators.match_op: lambda x, y: "CONTAINS (%s, %s)" % (x, y) + }) functions = compiler.DefaultCompiler.functions.copy() functions.update ( diff --git a/lib/sqlalchemy/databases/mysql.py b/lib/sqlalchemy/databases/mysql.py index e2ee5330c..f40fa71c1 100644 --- a/lib/sqlalchemy/databases/mysql.py +++ b/lib/sqlalchemy/databases/mysql.py @@ -1887,7 +1887,8 @@ class MySQLCompiler(compiler.DefaultCompiler): operators = compiler.DefaultCompiler.operators.copy() operators.update({ sql_operators.concat_op: lambda x, y: "concat(%s, %s)" % (x, y), - sql_operators.mod: '%%' + sql_operators.mod: '%%', + sql_operators.match_op: lambda x, y: "MATCH (%s) AGAINST (%s IN BOOLEAN MODE)" % (x, y) }) functions = compiler.DefaultCompiler.functions.copy() functions.update ({ diff --git a/lib/sqlalchemy/databases/oracle.py b/lib/sqlalchemy/databases/oracle.py index 815024a00..f2e5ba2f6 100644 --- a/lib/sqlalchemy/databases/oracle.py +++ b/lib/sqlalchemy/databases/oracle.py @@ -584,7 +584,8 @@ class OracleCompiler(compiler.DefaultCompiler): operators = compiler.DefaultCompiler.operators.copy() operators.update( { - sql_operators.mod : lambda x, y:"mod(%s, %s)" % (x, y) + sql_operators.mod : lambda x, y:"mod(%s, %s)" % (x, y), + sql_operators.match_op: lambda x, y: "CONTAINS (%s, %s)" % (x, y) } ) diff --git a/lib/sqlalchemy/databases/postgres.py b/lib/sqlalchemy/databases/postgres.py index 6e77f02d8..9adade2a6 100644 --- a/lib/sqlalchemy/databases/postgres.py +++ b/lib/sqlalchemy/databases/postgres.py @@ -648,6 +648,7 @@ class PGCompiler(compiler.DefaultCompiler): sql_operators.mod : '%%', sql_operators.ilike_op: lambda x, y, escape=None: '%s ILIKE %s' % (x, y) + (escape and ' ESCAPE \'%s\'' % escape or ''), sql_operators.notilike_op: lambda x, y, escape=None: '%s NOT ILIKE %s' % (x, y) + (escape and ' ESCAPE \'%s\'' % escape or ''), + sql_operators.match_op: lambda x, y: '%s @@ to_tsquery(%s)' % (x, y), } ) |