I don't really know, because AbstractConcreteBase works pretty poorly and it's 
better to use other patterns.

Try this workaround, which I have no idea if it helps in this case:

class A(...):

 # ...


 @classmethod
 def __declare_last__(cls):
 cls.__mapper__.with_polymorphic = ("*", cls.__mapper__.local_table)


otherwise provide a more complete example and I'll try to diagnose why it 
doesnt work for this case.


On Wed, Mar 25, 2020, at 12:30 PM, Benjamin Beguin wrote:
> Hi there,
> 
> I'm facing an issue with the use of AbstractConcreteBase class and a 
> @declarred_attr returning a query_expression()
> 
> 
> class A(AbstractConcreteBase, Base):
> @declared_attr
> def foo(cls):
> return query_expression()
> 
> 
> class B(A):
> ...
> 
> 
> class C(A):
> ...
> 
> 
> objects = db.session.query(A).options(with_expression(A.foo, 
> my_expression)).all()
> 
> 
> 
> B and C objects returned have the property foo but it is None
> The generated SQL query returns a value for the expression but the mapping 
> seems to be not effective 
> 
> Am I doing something wrong ?
> 

> --
>  SQLAlchemy - 
>  The Python SQL Toolkit and Object Relational Mapper
> 
> http://www.sqlalchemy.org/
> 
>  To post example code, please provide an MCVE: Minimal, Complete, and 
> Verifiable Example. See http://stackoverflow.com/help/mcve for a full 
> description.
>  --- 
>  You received this message because you are subscribed to the Google Groups 
> "sqlalchemy" group.
>  To unsubscribe from this group and stop receiving emails from it, send an 
> email to sqlalchemy+unsubscr...@googlegroups.com.
>  To view this discussion on the web visit 
> https://groups.google.com/d/msgid/sqlalchemy/a071d191-73d1-4519-8625-068903b3950c%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/sqlalchemy/a071d191-73d1-4519-8625-068903b3950c%40googlegroups.com?utm_medium=email&utm_source=footer>.

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sqlalchemy/dd8b6a29-92b4-4238-a9cd-f7aa22f678c2%40www.fastmail.com.

Reply via email to