changeset ec2fc6da64aa in trytond:default
details: https://hg.tryton.org/trytond?cmd=changeset&node=ec2fc6da64aa
description:
Alter column type to change size on postgresql table
issue7331
diffstat:
trytond/backend/postgresql/table.py | 14 +-------------
1 files changed, 1 insertions(+), 13 deletions(-)
diffs (27 lines):
diff -r 892807681516 -r ec2fc6da64aa trytond/backend/postgresql/table.py
--- a/trytond/backend/postgresql/table.py Mon Apr 12 23:07:55 2021 +0200
+++ b/trytond/backend/postgresql/table.py Tue Apr 13 01:41:30 2021 +0200
@@ -218,22 +218,10 @@
def alter_size(self, column_name, column_type):
cursor = Transaction().connection.cursor()
cursor.execute(
- SQL(
- "ALTER TABLE {} RENAME COLUMN {} TO _temp_change_size").format(
- Identifier(self.table_name),
- Identifier(column_name)))
- cursor.execute(SQL("ALTER TABLE {} ADD COLUMN {} {}").format(
+ SQL("ALTER TABLE {} ALTER COLUMN {} TYPE {}").format(
Identifier(self.table_name),
Identifier(column_name),
SQL(column_type)))
- cursor.execute(
- SQL("UPDATE {} SET {} = _temp_change_size::%s").format(
- Identifier(self.table_name),
- Identifier(column_name),
- SQL(column_type)))
- cursor.execute(
- SQL("ALTER TABLE {} " "DROP COLUMN _temp_change_size")
- .format(Identifier(self.table_name)))
self._update_definitions(columns=True)
def alter_type(self, column_name, column_type):