Re: [sqlalchemy] Relationship through association table

2018-12-28 Thread Mike Bayer
On Fri, Dec 28, 2018 at 9:21 AM Mehdi Gmira wrote: > > I have one example illustrating that A.b.id does not pick up the correct id okey doke, set that all up explicitly as below, will update the example now, thanks for the complete test B_viacd = mapper(B, j, non_primary=True,

Re: [sqlalchemy] Relationship through association table

2018-12-28 Thread Mehdi Gmira
I have one example illustrating that A.b.id does not pick up the correct id from sqlalchemy import Column, DateTime, String, Integer, ForeignKey, func, Table, create_engine, join from sqlalchemy.orm import relationship, backref, sessionmaker, joinedload, contains_eager, mapper from

Re: [sqlalchemy] Relationship through association table

2018-12-28 Thread Mike Bayer
On Fri, Dec 28, 2018 at 4:24 AM Mehdi Gmira wrote: > > Thanks for the reply. There is something I don't understand in the example: > > B_viacd = mapper(B, j, non_primary=True, properties={ > "b_id": [j.c.b_id, j.c.d_b_id], > "d_id": j.c.d_id > }) > > > How Is the mapper supposed to

Re: [sqlalchemy] Relationship through association table

2018-12-28 Thread Mehdi Gmira
Thanks for the reply. There is something I don't understand in the example: B_viacd = mapper(B, j, non_primary=True, properties={ "b_id": [j.c.b_id, j.c.d_b_id], "d_id": j.c.d_id }) How Is the mapper supposed to map the results of j with the class B ? the statement behind j is:

Re: [sqlalchemy] Relationship through association table

2018-12-27 Thread Mike Bayer
the section at https://docs.sqlalchemy.org/en/latest/orm/join_conditions.html#relationship-to-non-primary-mapper has a recipe for: "when we seek to join from A to B, making use of any number of C, D, etc. in between, however there are also join conditions between A and B directly", I think that's

[sqlalchemy] Relationship through association table

2018-12-27 Thread mgmira
from sqlalchemy import Column, DateTime, String, Integer, ForeignKey, func, Table, create_engine from sqlalchemy.orm import relationship, backref, sessionmaker, joinedload, contains_eager from sqlalchemy.ext.declarative import declarative_base Base = declarative_base() engine =