hooks/syncschema.py
branchstable
changeset 5834 b8ad49864928
parent 5833 d7256ae7c1d1
child 5845 4e28f03651d4
equal deleted inserted replaced
5833:d7256ae7c1d1 5834:b8ad49864928
   582         column = SQL_PREFIX + str(self.rdef.rtype)
   582         column = SQL_PREFIX + str(self.rdef.rtype)
   583         # alter the physical schema on size/unique constraint changes
   583         # alter the physical schema on size/unique constraint changes
   584         if cstrtype == 'SizeConstraint':
   584         if cstrtype == 'SizeConstraint':
   585             try:
   585             try:
   586                 adbh = self.session.pool.source('system').dbhelper
   586                 adbh = self.session.pool.source('system').dbhelper
   587                 coltype = y2sql.type_from_constraints(adbh, rdef.object, [],
   587                 coltype = y2sql.type_from_constraints(adbh, self.rdef.object, [],
   588                                                       creating=False)
   588                                                       creating=False)
   589     
   589     
   590                 if getattr(adbh, 'alter_table_requires_cursor', False):
   590                 if getattr(adbh, 'alter_table_requires_cursor', False):
   591                     sql = adbh.sql_change_col_type(table, column, coltype,
   591                     sql = adbh.sql_change_col_type(table, column, coltype,
   592                                                    rdef.cardinality[0] != '1',
   592                                                    self.rdef.cardinality[0] != '1',
   593                                                    self.session.system_sql)
   593                                                    self.session.system_sql)
   594                 else:
   594                 else:
   595                     sql = adbh.sql_change_col_type(table, column, coltype,
   595                     sql = adbh.sql_change_col_type(table, column, coltype,
   596                                                rdef.cardinality[0] != '1')
   596                                                self.rdef.cardinality[0] != '1')
   597                 
   597                 
   598                 self.session.system_sql(sql, rollback_on_failure=False)
   598                 self.session.system_sql(sql, rollback_on_failure=False)
   599                 self.info('altered column %s of table %s: now %s',
   599                 self.info('altered column %s of table %s: now %s',
   600                           column, table, coltype)
   600                           column, table, coltype)
   601             except Exception, ex:
   601             except Exception, ex: