Open theelderbeever opened 2 years ago
That's strange - I wonder if there's some kind of edge case. Do you mind sharing what the column name / type was for your custom primary key, and whether you defined multiple new columns on the table at the same time?
Ah I figured out the initial issue... I am using a BaseTable
class that inherits from Table
in order to add utility methods. The base class was generating the id
column.
So something like this.
class BaseTable(Table):
@classmethod
async def do_somthing(cls):
...
class MyTable(BaseTable):
address = Text(primary_key=True)
With that it seems like inheritance might not work. I don't believe a Mixin will either since these are classmethod
s. Any thoughts on composability/extending a Base piccolo table?
Further update the following appears to work but the order of the Mixins is critical (at least for some of the methods we wrote).
class BaseTable:
@classmethod
async def do_somthing(cls):
...
# This works
class MyTable(BaseTable, Table):
address = Text(primary_key=True)
# This does not
class MyTable(Table, BaseTable):
address = Text(primary_key=True)
OK, interesting - the docs around mixins need expanding upon to cover these details. We just have this currently.
Defining your own primary key column used to prevent the generation of the
id
column. As of piccolo 0.74.x it appears to still generate theid
column causing amultiple primary key
error when applying the migration.