Subject: changeset in trytond:5.0 Correctly rename column with SQLite From: Cédric Krier <[email protected]>
changeset ea510f2ffe05 in trytond:5.0 details: https://hg.tryton.org/trytond?cmd=changeset;node=ea510f2ffe05 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 3c42b7c8c46c -r ea510f2ffe05 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( @@ -322,7 +322,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.items():
