@@ -435,27 +435,19 @@ def alter_column_type(cr, table, column, type, using=None, logger=_logger):
435
435
using = "{{0}}::{}" .format (type )
436
436
437
437
# else, create a new column and parallel update queries.
438
- cr .execute (
439
- """
440
- ALTER TABLE "{table}" RENAME COLUMN "{column}" TO "_{column}_upg";
441
- ALTER TABLE "{table}" ADD COLUMN "{column}" {type};
442
- """ .format (** locals ())
443
- )
444
- using = using .format ('"_{}_upg"' .format (column ))
445
- parallel_execute (
438
+ tmp_column = "_{}_upg" .format (column )
439
+ cr .execute (format_query (cr , "ALTER TABLE {} RENAME COLUMN {} TO {}" , table , column , tmp_column ))
440
+ cr .execute (format_query (cr , "ALTER TABLE {} ADD COLUMN {} {}" , table , column , sql .SQL (type )))
441
+
442
+ using = sql .SQL (format_query (cr , using , tmp_column ))
443
+ explode_execute (
446
444
cr ,
447
- explode_query_range (
448
- cr ,
449
- """
450
- UPDATE "{table}"
451
- SET "{column}" = {using}
452
- WHERE "_{column}_upg" IS NOT NULL
453
- """ .format (** locals ()),
454
- table = table ,
455
- ),
445
+ format_query (cr , "UPDATE {} SET {} = {} WHERE {} IS NOT NULL" , table , column , using , tmp_column ),
446
+ table = table ,
456
447
logger = logger ,
457
448
)
458
- cr .execute ('ALTER TABLE "{table}" DROP COLUMN "_{column}_upg" CASCADE' .format (** locals ()))
449
+
450
+ cr .execute (format_query (cr , "ALTER TABLE {} DROP COLUMN {} CASCADE" , table , tmp_column ))
459
451
460
452
461
453
def table_exists (cr , table ):
0 commit comments