--- a/hooks/syncschema.py Thu Dec 09 14:35:20 2010 +0000
+++ b/hooks/syncschema.py Thu Dec 09 14:55:51 2010 +0100
@@ -282,13 +282,15 @@
self.session.vreg.schema.rename_entity_type(oldname, newname)
# we need sql to operate physical changes on the system database
sqlexec = self.session.system_sql
- sqlexec('ALTER TABLE %s%s RENAME TO %s%s' % (SQL_PREFIX, oldname,
- SQL_PREFIX, newname))
+ dbhelper= self.session.pool.source('system').dbhelper
+ sql = dbhelper.sql_rename_table(SQL_PREFIX+oldname,
+ SQL_PREFIX+newname)
+ sqlexec(sql)
self.info('renamed table %s to %s', oldname, newname)
- sqlexec('UPDATE entities SET type=%s WHERE type=%s',
- (newname, oldname))
- sqlexec('UPDATE deleted_entities SET type=%s WHERE type=%s',
- (newname, oldname))
+ sqlexec('UPDATE entities SET type=%(newname)s WHERE type=%(oldname)s',
+ {'newname': newname, 'oldname': oldname))
+ sqlexec('UPDATE deleted_entities SET type=%(newname)s WHERE type=%(oldname)s',
+ {'newname': newname, 'oldname': oldname))
# XXX transaction records
def precommit_event(self):
--- a/server/schemaserial.py Thu Dec 09 14:35:20 2010 +0000
+++ b/server/schemaserial.py Thu Dec 09 14:55:51 2010 +0100
@@ -126,8 +126,9 @@
sqlexec('UPDATE %(p)sCWEType SET %(p)sname=%%(n)s WHERE %(p)seid=%%(x)s'
% {'p': sqlutils.SQL_PREFIX}, {'x': eid, 'n': netype})
if etype.lower() != netype.lower():
- sqlexec('ALTER TABLE %s%s RENAME TO %s%s' % (
- sqlutils.SQL_PREFIX, etype, sqlutils.SQL_PREFIX, netype))
+ alter_table_sql = dbhelper.sql_rename_table(sqlutils.SQL_PREFIX+etype,
+ sqlutils.SQL_PREFIX+netype)
+ sqlexec(alter_table_sql)
sqlexec('UPDATE entities SET type=%(n)s WHERE type=%(x)s',
{'x': etype, 'n': netype})
session.commit(False)