dynamorm
dynamorm copied to clipboard
Is Table inheritance possible?
Is building the Dynamodel's subclass Table attribute through inheritance supported?
class BaseTable:
hash_key = 'someid'
read = 3
write = 4
class ActualTable(DynaModel):
class Table(BaseTable):
name = 'table-name'
class Schema:
someid = fields.String(required=True)
Doing so raises dynamorm.exceptions.MissingTableAttribute: Missing required Table attribute: hash_key
errors. I see that the dynamorm metaclass is doing some fancy stuff behind the scenes with the Table attribute, but it does that with Schemas too and Schema inheritance is supported now.
Is there a suggested way to do what I'm looking for with Table inheritance?
We don't currently support Table
inheritance because of the way our meta-class works. We would need to do something similar to #46 where we added support for inheritance on the Model
.
Great to know, thank you @borgstrom !
I'm assuming you can't sufficiently predict the table name beforehand? I use a function to generate part of the table name dynamically (for dev/staging/prod).
On Thu, Jun 18, 2020 at 5:58 AM Thomas Passer Jensen < [email protected]> wrote:
Does a workaround exist for when the table named is not known when the model class is defined? When a table is defined in CloudFormation without the TableName attribute it receives an autogenerated "unique physical ID".
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/NerdWalletOSS/dynamorm/issues/96#issuecomment-645915936, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABR2MRNSY5VMO2UMUUGJA7DRXHQNDANCNFSM4KKXQKNQ .