Skip to content

Commit

Permalink
handle setup of nested arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
dantownsend committed Mar 4, 2024
1 parent 4f66bd8 commit f30a96f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions piccolo/columns/column_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -2588,6 +2588,15 @@ def column_type(self):
return "ARRAY"
raise Exception("Unrecognized engine type")

def _setup_base_column(self, table_class: t.Type[Table]):
"""
Called from the ``Table.__init_subclass__`` - makes sure
that the ``base_column`` has a reference to the parent table.
"""
self.base_column._meta._table = table_class
if isinstance(self.base_column, Array):
self.base_column._setup_base_column(table_class=table_class)

def __getitem__(self, value: int) -> Array:
"""
Allows queries which retrieve an item from the array. The index starts
Expand Down
2 changes: 1 addition & 1 deletion piccolo/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ def __init_subclass__(
column._meta._table = cls

if isinstance(column, Array):
column.base_column._meta._table = cls
column._setup_base_column(table_class=cls)

if isinstance(column, Email):
email_columns.append(column)
Expand Down

0 comments on commit f30a96f

Please sign in to comment.