Subject: changeset in trytond:4.8 Correctly rename column with SQLite From: Cédric Krier <[email protected]>
changeset 9c751a18633c in trytond:4.8 details: https://hg.tryton.org/trytond?cmd=changeset;node=9c751a18633c description: Correctly rename column with SQLite The table must be recreated if the target column does not exist. Also temporary column name should use double underscore as module may use single underscore. issue7978 review52591002 (grafted from c4ec4f7d98665d93dd8d2325321870401d428178) diffstat: trytond/backend/sqlite/table.py | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diffs (30 lines): diff -r 25fd9de7bf7e -r 9c751a18633c trytond/backend/sqlite/table.py --- a/trytond/backend/sqlite/table.py Tue Jan 15 00:02:19 2019 +0100 +++ b/trytond/backend/sqlite/table.py Tue Jan 15 11:30:20 2019 +0100 @@ -93,7 +93,7 @@ transaction = Transaction() database = transaction.database cursor = transaction.connection.cursor() - temp_table = '_temp_%s' % self.table_name + temp_table = '__temp_%s' % self.table_name TableHandler.table_rename(self.table_name, temp_table) new_table = TableHandler(self._model, history=self.history) columns, old_columns = [], [] @@ -116,7 +116,7 @@ def column_rename(self, old_name, new_name): if self.column_exist(old_name): - if self.column_exist(new_name): + if not self.column_exist(new_name): self._recreate_table({old_name: {'name': new_name}}) else: logger.warning( @@ -293,7 +293,7 @@ transaction = Transaction() database = transaction.database cursor = transaction.connection.cursor() - temp_table = '_temp_%s' % self.table_name + temp_table = '__temp_%s' % self.table_name TableHandler.table_rename(self.table_name, temp_table) new_table = TableHandler(self._model, history=self.history) for name, values in self._columns.iteritems():
