On Wed, Jun 21, 2023, at 5:12 AM, Julien Cigar wrote:
> Hello,
>
> I'm trying to add a column_property to recursively load and merge some
> json column.
>
> I have the following:
> https://gist.github.com/silenius/1af1072abae5829f54584f1ea554e074 but I
> cannot figure how can I replace the '5011' at line 11 (which is the
> object primary key) with the "current" involved objet..?
>
> For example when I'm doing dbsession.get(MyClass, 1234) I cannot figure
> how reference the id in the column_property query

well you wouldnt hardcode the id like that, you'd need to make your query 
correlated to the parent.

so it would select() from "ac" where "ac" is "aliased(class_)" , then correlate 
to the class


.where(
        class_.id == ac.id 
).


as far as how that integrates into the CTE and all that you'd have to arrange 
the geometry of the SELECT to work out correctly, I would start with something 
very simple and build outwards.

correlated subquery column_property at 
https://docs.sqlalchemy.org/en/20/orm/mapped_sql_expr.html#using-column-property

-- 
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/400b6b72-f601-47c8-aa30-827240097eb8%40app.fastmail.com.

Reply via email to