[PonyORM-list] Inheritence

Alexander Kozlovsky alexander.kozlovsky at gmail.com
Tue Jul 8 06:58:21 UTC 2014

Hi Matthew!

As a workaround, you can explicitly specify unique column name for each
conflicted attribute:

class A(Base):
  x = Optional(int)
  y = Optional(int, column="A_y")

class B(Base):
  y = Optional(int, column="B_y")
  z = Optional(int)

In future we probably should silently use the same column for two or more
sibling classes if column definition is exactly the same in each class.

On Tue, Jul 8, 2014 at 2:48 AM, Matthew Bell <matthewrobertbell at gmail.com>

> Hi,
> I have a project where it is intuitive to model the data by creating a
> bunch of models which all inherit from a base model, and share a lot of the
> same attributes (they'd be storing results of very similar processes).
> Here is how I tried to attempt it:
> https://gist.github.com/anonymous/26a8ff2bbfe38bea32ef
> This fails, because "DBSchemaError: Column 'y' already exists in table
> 'Base'".
> I can do it like this:
> https://gist.github.com/anonymous/e70f7aebacea9e97ff90
> It works, but quickly becomes messy when I have many attributes (up to
> around 30 would be needed), as there would be many useless classes, and
> inheriting from say 10 classes at once does not seem clear to me, compared
> to just defining repeated attributes. Is there a way I can make the former
> example work, or am I missing an alternative technique to get the same
> result? It seems advantageous to inherit from a base, so that it is easy to
> search all data by issuing queries on only one table.
> Thanks
> --
> Regards,
> Matthew Bell
> _______________________________________________
> ponyorm-list mailing list
> ponyorm-list at ponyorm.com
> /ponyorm-list
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </ponyorm-list/attachments/20140708/0d5407b7/attachment.html>

More information about the ponyorm-list mailing list