Skip to content

Commit 5d24564

Browse files
committed
[IMP] alter_column_type
Document function. closes #226 Signed-off-by: Christophe Simonis (chs) <[email protected]>
1 parent 38a3222 commit 5d24564

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/util/pg.py

+14
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,20 @@ def remove_column(cr, table, column, cascade=False):
614614

615615

616616
def alter_column_type(cr, table, column, type, using=None, where=None, logger=_logger):
617+
"""
618+
Alter the type of a column.
619+
620+
Do it efficiently using a temporary column and parallel UPDATE queries.
621+
622+
:param str table: name of the affected table.
623+
:param str column: name of the column to alter type.
624+
:param str type: new type of the column.
625+
:param str using: SQL expression that define how to convert the value to the new type.
626+
The `{0}` placeholder will be replaced by the column name.
627+
:param str where: used to restrict the values converted via `using`.
628+
:param logger: logger used to report the progress.
629+
:type logger: :class:`logging.Logger`
630+
"""
617631
if where and not using:
618632
raise ValueError("`where` parameter is only relevant with a non-default `using` parameter")
619633

0 commit comments

Comments
 (0)