]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
MSSQL now compiles func.now() to CURRENT_TIMESTAMP
authorRick Morrison <rickmorrison@gmail.com>
Thu, 14 Feb 2008 18:38:24 +0000 (18:38 +0000)
committerRick Morrison <rickmorrison@gmail.com>
Thu, 14 Feb 2008 18:38:24 +0000 (18:38 +0000)
CHANGES
lib/sqlalchemy/databases/mssql.py

diff --git a/CHANGES b/CHANGES
index 210467b5acbe23834c426076553ad847bfeb4311..6b535be2f614c11db2b36f20df01a2d41492a9fd 100644 (file)
--- 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
index 6063e84693733fe23dcf0d194033b870ea5e5f27..b9706da7428e04b2e250b008e76b6894527aba2b 100644 (file)
@@ -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 = {}