hooks/syncschema.py
changeset 8179 e52a084e955c
parent 8178 2d62b6017700
child 8190 2a3c1b787688
child 8192 0067653190c7
equal deleted inserted replaced
8172:77aa753dcd6b 8179:e52a084e955c
   485         rschema.final = True
   485         rschema.final = True
   486         insert_rdef_on_subclasses(session, eschema, rschema, rdefdef, props)
   486         insert_rdef_on_subclasses(session, eschema, rschema, rdefdef, props)
   487         # set default value, using sql for performance and to avoid
   487         # set default value, using sql for performance and to avoid
   488         # modification_date update
   488         # modification_date update
   489         if default:
   489         if default:
   490             if  rdefdef.object in ('Date', 'Datetime'):
   490             if rdefdef.object in ('Date', 'Datetime', 'TZDatetime'):
       
   491                 # XXX may may want to use creation_date
   491                 if default == 'TODAY':
   492                 if default == 'TODAY':
   492                     default = syssource.dbhelper.sql_current_date()
   493                     default = syssource.dbhelper.sql_current_date()
   493                 elif default == 'NOW':
   494                 elif default == 'NOW':
   494                     default = syssource.dbhelper.sql_current_timestamp()
   495                     default = syssource.dbhelper.sql_current_timestamp()
   495             session.system_sql('UPDATE %s SET %s=%%(default)s' % (table, column),
   496                 session.system_sql('UPDATE %s SET %s=%(default)s'
   496                                {'default': default})
   497                                    % (table, column, default))
       
   498             else:
       
   499                 session.system_sql('UPDATE %s SET %s=%%(default)s' % (table, column),
       
   500                                    {'default': default})
   497 
   501 
   498     def revertprecommit_event(self):
   502     def revertprecommit_event(self):
   499         # revert changes on in memory schema
   503         # revert changes on in memory schema
   500         self.session.vreg.schema.del_relation_def(
   504         self.session.vreg.schema.del_relation_def(
   501             self.rdefdef.subject, self.rdefdef.name, self.rdefdef.object)
   505             self.rdefdef.subject, self.rdefdef.name, self.rdefdef.object)