Julien Cigar <jci...@ulb.ac.be> wrote:

> 
> Hi Mike,
> 
> Sorry to bother you once with this, but I've re-read all the docs on
> the relationships and I want to be sure that I've understand correctly.
> 
> Imagine I have the following "link" table in SQL:
> https://gist.github.com/silenius/77d406f8e0c0e26eb38f with the following
> mappers: https://gist.github.com/silenius/18190ef4912667e49b1a
> 
> So basically you have Accounts, Pools, Roles and a link table
> AccountRole
> 
> What I would like is to have on the Pool object the list of Account 
> who have a Role 'facilitator' for a certain Pool.
> 
> The result is at line 18-26 of the paste
> (https://gist.github.com/silenius/18190ef4912667e49b1a#file-gistfile1-py-L18-L26),
>  I wondered if it was okay because I sometimes mix the primaryjoin and 
> secondaryjoin clauses... If I understand well I don't need a primaryjoin 
> clause
> in this case ..? 

I don’t know offhand, if you turn on INFO logging for the “sqlalchemy.orm”
logger you’ll see every decision SQLAlchemy is making:

from sqlalchemy import *
from sqlalchemy.orm import *
from sqlalchemy.ext.declarative import declarative_base

Base = declarative_base()


class A(Base):
    __tablename__ = 'a'
    id = Column(Integer, primary_key=True)
    bs = relationship("B")


class B(Base):
    __tablename__ = 'b'
    id = Column(Integer, primary_key=True)
    a_id = Column(ForeignKey('a.id'))

import logging
logging.basicConfig()
logging.getLogger("sqlalchemy.orm").setLevel(logging.INFO)

configure_mappers()


output:

INFO:sqlalchemy.orm.mapper.Mapper:(B|b) _post_configure_properties() started
INFO:sqlalchemy.orm.mapper.Mapper:(B|b) initialize prop id
INFO:sqlalchemy.orm.mapper.Mapper:(B|b) initialize prop a_id
INFO:sqlalchemy.orm.mapper.Mapper:(B|b) _post_configure_properties() complete
INFO:sqlalchemy.orm.mapper.Mapper:(A|a) _post_configure_properties() started
INFO:sqlalchemy.orm.mapper.Mapper:(A|a) initialize prop bs
INFO:sqlalchemy.orm.relationships.RelationshipProperty:A.bs setup primary join 
a.id = b.a_id
INFO:sqlalchemy.orm.relationships.RelationshipProperty:A.bs setup secondary 
join None
INFO:sqlalchemy.orm.relationships.RelationshipProperty:A.bs synchronize pairs 
[(a.id => b.a_id)]
INFO:sqlalchemy.orm.relationships.RelationshipProperty:A.bs secondary 
synchronize pairs []
INFO:sqlalchemy.orm.relationships.RelationshipProperty:A.bs local/remote pairs 
[(a.id / b.a_id)]
INFO:sqlalchemy.orm.relationships.RelationshipProperty:A.bs remote columns 
[b.a_id]
INFO:sqlalchemy.orm.relationships.RelationshipProperty:A.bs local columns [a.id]
INFO:sqlalchemy.orm.relationships.RelationshipProperty:A.bs relationship 
direction symbol('ONETOMANY')
INFO:sqlalchemy.orm.strategies.LazyLoader:A.bs lazy loading clause :param_1 = 
b.a_id
INFO:sqlalchemy.orm.mapper.Mapper:(A|a) initialize prop id
INFO:sqlalchemy.orm.mapper.Mapper:(A|a) _post_configure_properties() complete







> 
> Thanks,
> Julien
> 
>>>>>> I'm using PostgreSQL, and I checked that all constraints are properly
>>>>>> created on server-side but I haven't checked with sqllite:// 
>>>>>> 
>>>>>>>> Thanks,
>>>>>>>> Julien
>>>>>>>> 
>>>>>>>> 
>>>>>>>>>>> -- 
>>>>>>>>>>> Julien Cigar
>>>>>>>>>>> Belgian Biodiversity Platform (http://www.biodiversity.be)
>>>>>>>>>>> PGP fingerprint: EEF9 F697 4B68 D275 7B11  6A25 B2BB 3710 A204 23C0
>>>>>>>>>>> No trees were killed in the creation of this message.
>>>>>>>>>>> However, many electrons were terribly inconvenienced.
>>>>>>>>>>> 
>>>>>>>>>>> -- 
>>>>>>>>>>> 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 post to this group, send email to sqlalchemy@googlegroups.com.
>>>>>>>>>>> Visit this group at http://groups.google.com/group/sqlalchemy.
>>>>>>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>> -- 
>>>>>>>>>> Julien Cigar
>>>>>>>>>> Belgian Biodiversity Platform (http://www.biodiversity.be)
>>>>>>>>>> PGP fingerprint: EEF9 F697 4B68 D275 7B11  6A25 B2BB 3710 A204 23C0
>>>>>>>>>> No trees were killed in the creation of this message.
>>>>>>>>>> However, many electrons were terribly inconvenienced.
>>>>>>>>>> 
>>>>>>>>>> -- 
>>>>>>>>>> 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 post to this group, send email to sqlalchemy@googlegroups.com.
>>>>>>>>>> Visit this group at http://groups.google.com/group/sqlalchemy.
>>>>>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>>>> 
>>>>>>>>> -- 
>>>>>>>>> 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 post to this group, send email to sqlalchemy@googlegroups.com.
>>>>>>>>> Visit this group at http://groups.google.com/group/sqlalchemy.
>>>>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>>> 
>>>>>>>> -- 
>>>>>>>> Julien Cigar
>>>>>>>> Belgian Biodiversity Platform (http://www.biodiversity.be)
>>>>>>>> PGP fingerprint: EEF9 F697 4B68 D275 7B11  6A25 B2BB 3710 A204 23C0
>>>>>>>> No trees were killed in the creation of this message.
>>>>>>>> However, many electrons were terribly inconvenienced.
>>>>>>>> 
>>>>>>>> -- 
>>>>>>>> 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 post to this group, send email to sqlalchemy@googlegroups.com.
>>>>>>>> Visit this group at http://groups.google.com/group/sqlalchemy.
>>>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>> 
>>>>>>> -- 
>>>>>>> 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 post to this group, send email to sqlalchemy@googlegroups.com.
>>>>>>> Visit this group at http://groups.google.com/group/sqlalchemy.
>>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>> 
>>>>>> -- 
>>>>>> Julien Cigar
>>>>>> Belgian Biodiversity Platform (http://www.biodiversity.be)
>>>>>> PGP fingerprint: EEF9 F697 4B68 D275 7B11  6A25 B2BB 3710 A204 23C0
>>>>>> No trees were killed in the creation of this message.
>>>>>> However, many electrons were terribly inconvenienced.
>>>>>> 
>>>>>> -- 
>>>>>> 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 post to this group, send email to sqlalchemy@googlegroups.com.
>>>>>> Visit this group at http://groups.google.com/group/sqlalchemy.
>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>> 
>>>>> -- 
>>>>> 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 post to this group, send email to sqlalchemy@googlegroups.com.
>>>>> Visit this group at http://groups.google.com/group/sqlalchemy.
>>>>> For more options, visit https://groups.google.com/d/optout.
>>>> 
>>>> -- 
>>>> Julien Cigar
>>>> Belgian Biodiversity Platform (http://www.biodiversity.be)
>>>> PGP fingerprint: EEF9 F697 4B68 D275 7B11  6A25 B2BB 3710 A204 23C0
>>>> No trees were killed in the creation of this message.
>>>> However, many electrons were terribly inconvenienced.
>>>> 
>>>> -- 
>>>> 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 post to this group, send email to sqlalchemy@googlegroups.com.
>>>> Visit this group at http://groups.google.com/group/sqlalchemy.
>>>> For more options, visit https://groups.google.com/d/optout.
>>> 
>>> 
>>> 
>>> -- 
>>> Julien Cigar
>>> Belgian Biodiversity Platform (http://www.biodiversity.be)
>>> PGP fingerprint: EEF9 F697 4B68 D275 7B11  6A25 B2BB 3710 A204 23C0
>>> No trees were killed in the creation of this message.
>>> However, many electrons were terribly inconvenienced.
>>> 
>>> -- 
>>> 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 post to this group, send email to sqlalchemy@googlegroups.com.
>>> Visit this group at http://groups.google.com/group/sqlalchemy.
>>> For more options, visit https://groups.google.com/d/optout.
>> 
>> -- 
>> 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 post to this group, send email to sqlalchemy@googlegroups.com.
>> Visit this group at http://groups.google.com/group/sqlalchemy.
>> For more options, visit https://groups.google.com/d/optout.
> 
> -- 
> Julien Cigar
> Belgian Biodiversity Platform (http://www.biodiversity.be)
> PGP fingerprint: EEF9 F697 4B68 D275 7B11  6A25 B2BB 3710 A204 23C0
> No trees were killed in the creation of this message.
> However, many electrons were terribly inconvenienced.
> 
> -- 
> 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 post to this group, send email to sqlalchemy@googlegroups.com.
> Visit this group at http://groups.google.com/group/sqlalchemy.
> For more options, visit https://groups.google.com/d/optout.

-- 
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 post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to