Hi All, I'm trying to find the solution but with no success

I have 2 tables related through assoc table

table a
id   |name    |
-----|--------|
1    |example |

assoc
id   |a_id | b_id |
-----|-----|------|
1    |1    |1     |
2    |1    |2     |

table b  
id   |name     |
-----|---------|
1    |example1 |
2    |example2 |  


Of course I've mapped classes through orm.
I want to select all records from a join b and then group by a object and 
aggregate all related records from b to an array of b objects:

( <model.TableA>, [<model.TableB>, <model.TableB>] )

So far I only found a solution of using some mix of postgresql dialect and 
sa 
like:
postgresql.array_agg(func.json_build_object("id", TableB.id, "name", 
TableB.name))
and I can produce

( <model.TableA>, [{"id":1, "name": "example1"}, {"id":2, "name": 
"example2"}] )  

but ideally would by the array of objects

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sqlalchemy/2d72d2bb-b07c-4220-92fb-dc7ce1839631n%40googlegroups.com.

Reply via email to