Skip to content

Commit dca04f2

Browse files
authored
fix bug with missing array base column imports when altering a column (#1227)
1 parent 15d18af commit dca04f2

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

piccolo/apps/migrations/auto/serialisation.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -738,6 +738,8 @@ def deserialise_params(params: dict[str, Any]) -> dict[str, Any]:
738738
if isinstance(value, str) and not isinstance(value, Enum):
739739
if value != "self":
740740
params[key] = deserialise_legacy_params(name=key, value=value)
741+
elif isinstance(value, SerialisedColumnInstance):
742+
params[key] = value.instance
741743
elif isinstance(value, SerialisedClassInstance):
742744
params[key] = value.instance
743745
elif isinstance(value, SerialisedUUID):

tests/apps/migrations/auto/integration/test_migrations.py

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -693,9 +693,13 @@ def test_array_column_varchar(self):
693693

694694
def test_array_column_bigint(self):
695695
"""
696-
There was a bug with using an array of ``BigInt`` - see issue 500 on
697-
GitHub. It's because ``BigInt`` requires access to the parent table to
696+
There was a bug with using an array of ``BigInt``:
697+
698+
http://github.com/piccolo-orm/piccolo/issues/500/
699+
700+
It's because ``BigInt`` requires access to the parent table to
698701
determine what the column type is.
702+
699703
"""
700704
self._test_migrations(
701705
table_snapshots=[
@@ -706,6 +710,26 @@ def test_array_column_bigint(self):
706710
]
707711
)
708712

713+
def test_array_base_column_change(self):
714+
"""
715+
There was a bug when trying to change the base column of an array:
716+
717+
https://github.com/piccolo-orm/piccolo/issues/1076
718+
719+
It wasn't importing the base column, e.g. for ``Array(Text())`` it
720+
wasn't importing ``Text``.
721+
722+
"""
723+
self._test_migrations(
724+
table_snapshots=[
725+
[self.table(column)]
726+
for column in [
727+
Array(base_column=Varchar()),
728+
Array(base_column=Text()),
729+
]
730+
]
731+
)
732+
709733
###########################################################################
710734

711735
# We deliberately don't test setting JSON or JSONB columns as indexes, as

0 commit comments

Comments
 (0)