124 else: |
124 else: |
125 # the new type doesn't exist, we should rename |
125 # the new type doesn't exist, we should rename |
126 sqlexec('UPDATE %(p)sCWEType SET %(p)sname=%%(n)s WHERE %(p)seid=%%(x)s' |
126 sqlexec('UPDATE %(p)sCWEType SET %(p)sname=%%(n)s WHERE %(p)seid=%%(x)s' |
127 % {'p': sqlutils.SQL_PREFIX}, {'x': eid, 'n': netype}) |
127 % {'p': sqlutils.SQL_PREFIX}, {'x': eid, 'n': netype}) |
128 if etype.lower() != netype.lower(): |
128 if etype.lower() != netype.lower(): |
129 sqlexec('ALTER TABLE %s%s RENAME TO %s%s' % ( |
129 alter_table_sql = dbhelper.sql_rename_table(sqlutils.SQL_PREFIX+etype, |
130 sqlutils.SQL_PREFIX, etype, sqlutils.SQL_PREFIX, netype)) |
130 sqlutils.SQL_PREFIX+netype) |
|
131 sqlexec(alter_table_sql) |
131 sqlexec('UPDATE entities SET type=%(n)s WHERE type=%(x)s', |
132 sqlexec('UPDATE entities SET type=%(n)s WHERE type=%(x)s', |
132 {'x': etype, 'n': netype}) |
133 {'x': etype, 'n': netype}) |
133 session.commit(False) |
134 session.commit(False) |
134 try: |
135 try: |
135 sqlexec('UPDATE deleted_entities SET type=%(n)s WHERE type=%(x)s', |
136 sqlexec('UPDATE deleted_entities SET type=%(n)s WHERE type=%(x)s', |