[schema synchronization] don't use sql for TODAY/NOW in keyword arg. Closes #2154815 stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 19 Jan 2012 18:44:41 +0100
branchstable
changeset 8178 2d62b6017700
parent 8177 e4ab883f07d9
child 8179 e52a084e955c
child 8182 d062d3b7da6c
[schema synchronization] don't use sql for TODAY/NOW in keyword arg. Closes #2154815 Also consider TZDatetime on the way
hooks/syncschema.py
--- a/hooks/syncschema.py	Mon Jan 23 12:36:33 2012 +0100
+++ b/hooks/syncschema.py	Thu Jan 19 18:44:41 2012 +0100
@@ -487,13 +487,17 @@
         # set default value, using sql for performance and to avoid
         # modification_date update
         if default:
-            if  rdefdef.object in ('Date', 'Datetime'):
+            if rdefdef.object in ('Date', 'Datetime', 'TZDatetime'):
+                # XXX may may want to use creation_date
                 if default == 'TODAY':
                     default = syssource.dbhelper.sql_current_date()
                 elif default == 'NOW':
                     default = syssource.dbhelper.sql_current_timestamp()
-            session.system_sql('UPDATE %s SET %s=%%(default)s' % (table, column),
-                               {'default': default})
+                session.system_sql('UPDATE %s SET %s=%(default)s'
+                                   % (table, column, default))
+            else:
+                session.system_sql('UPDATE %s SET %s=%%(default)s' % (table, column),
+                                   {'default': default})
 
     def revertprecommit_event(self):
         # revert changes on in memory schema