Re: [sqlalchemy] declared_attr not working with Postgres HSTORE

2020-08-22 Thread Mike Bayer
On Sat, Aug 22, 2020, at 12:36 PM, Saakshaat Singh wrote: > I agree that it's not practical for saving columns with the same name but in > our case, we had to give the child subclasses the same column names. > SQLAlchemy has declared_attr >

Re: [sqlalchemy] declared_attr not working with Postgres HSTORE

2020-08-22 Thread Mike Bayer
On Sat, Aug 22, 2020, at 12:33 PM, Saakshaat Singh wrote: > Thank you for looking into it Mike. I'll post an example today. > > But looking at your SQLAlchemy execution, I noticed that you're only passing > a value for the `child_value` field while the Parent class is polymorphic on > the

Re: [sqlalchemy] declared_attr not working with Postgres HSTORE

2020-08-22 Thread Saakshaat Singh
I agree that it's not practical for saving columns with the same name but in our case, we had to give the child subclasses the same column names. SQLAlchemy has declared_attr which converts the columns to scalar

Re: [sqlalchemy] declared_attr not working with Postgres HSTORE

2020-08-22 Thread Saakshaat Singh
Thank you for looking into it Mike. I'll post an example today. But looking at your SQLAlchemy execution, I noticed that you're only passing a value for the `child_value` field while the Parent class is polymorphic on the `ChildType` enum. So maybe it holds value to also pass values for the

Re: [sqlalchemy] declared_attr not working with Postgres HSTORE

2020-08-22 Thread Mike Bayer
If your model is based all on one table called "parent", it can only have one column called "child_value" and it can only be of a single database type, since that's your CREATE TABLE. I'm not able to follow what your example intends to do as you seem to be creating many Column objects with

Re: [sqlalchemy] declared_attr not working with Postgres HSTORE

2020-08-22 Thread Mike Bayer
Hi, I have no idea what the problem is and would need a fully runnable MCVE. Below is part of your test which I've tried to get running but it still errors out on identifiers missing and such, additionally I need a working example of exactly the session operations you are trying to achieve.

[sqlalchemy] declared_attr not working with Postgres HSTORE

2020-08-21 Thread Saakshaat Singh
Hi, I'm working with SQLAlchemy and Postgres and I have a polymorphic model whose subclasses have a field with the same name. To allow this field to co-exist with the others and not cause any name conflicts, I'm using the `declare_attr` decorator from SQLAlchemy. This solution works well for