[PonyORM-list] Inheritence

Роман Рубан ryr1986 at gmail.com
Tue Jul 8 09:01:04 UTC 2014


I think in this case A and B should be different tables by default


2014-07-08 13:58 GMT+07:00 Alexander Kozlovsky <
alexander.kozlovsky at gmail.com>:

> 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>
> wrote:
>
>> 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
>>
>>
>
> _______________________________________________
> ponyorm-list mailing list
> ponyorm-list at ponyorm.com
> /ponyorm-list
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </ponyorm-list/attachments/20140708/4edb1901/attachment.html>


More information about the ponyorm-list mailing list