From: Rick Morrison Date: Thu, 14 Feb 2008 18:38:24 +0000 (+0000) Subject: MSSQL now compiles func.now() to CURRENT_TIMESTAMP X-Git-Tag: rel_0_4_3~7 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8dd5eb402ef65194af4c54a6fd33a181b7d5eaf0;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git MSSQL now compiles func.now() to CURRENT_TIMESTAMP --- diff --git a/CHANGES b/CHANGES index 210467b5ac..6b535be2f6 100644 --- a/CHANGES +++ b/CHANGES @@ -27,9 +27,9 @@ CHANGES ILIKE on postgres, lower(x) LIKE lower(y) on all others. [ticket:727] - - Added "now()" as a generic function; on SQLite and Oracle - compiles as "CURRENT_TIMESTAMP"; "now()" on all others - [ticket:943] + - Added "now()" as a generic function; on SQLite, Oracle + and MSSQL compiles as "CURRENT_TIMESTAMP"; "now()" on + all others. [ticket:943] - The startswith(), endswith(), and contains() operators now concatenate the wildcard operator with the given operand in diff --git a/lib/sqlalchemy/databases/mssql.py b/lib/sqlalchemy/databases/mssql.py index 6063e84693..b9706da742 100644 --- a/lib/sqlalchemy/databases/mssql.py +++ b/lib/sqlalchemy/databases/mssql.py @@ -41,11 +41,12 @@ Known issues / TODO: import datetime, operator, random, re, sys from sqlalchemy import sql, schema, exceptions, util -from sqlalchemy.sql import compiler, expression, operators as sqlops +from sqlalchemy.sql import compiler, expression, operators as sqlops, functions as sql_functions from sqlalchemy.engine import default, base from sqlalchemy import types as sqltypes from sqlalchemy.util import Decimal as _python_Decimal + MSSQL_RESERVED_WORDS = util.Set(['function']) class MSNumeric(sqltypes.Numeric): @@ -874,6 +875,13 @@ class MSSQLCompiler(compiler.DefaultCompiler): operators = compiler.OPERATORS.copy() operators[sqlops.concat_op] = '+' + functions = compiler.DefaultCompiler.functions.copy() + functions.update ( + { + sql_functions.now: 'CURRENT_TIMESTAMP' + } + ) + def __init__(self, *args, **kwargs): super(MSSQLCompiler, self).__init__(*args, **kwargs) self.tablealiases = {}