changeset c4ec4f7d9866 in trytond:default
details: https://hg.tryton.org/trytond?cmd=changeset;node=c4ec4f7d9866
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
diffstat:

 trytond/backend/sqlite/table.py |  6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diffs (30 lines):

diff -r 269b7c6621ea -r c4ec4f7d9866 trytond/backend/sqlite/table.py
--- a/trytond/backend/sqlite/table.py   Tue Jan 15 00:09:38 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():

Reply via email to