Serge Koval wrote:
> Mike Conley wrote:
>> It looks like you can use the backref property to discover the other
>> side of the relation via the backref.prop attribute. From there you
>> should be able to find the the property on the other side by examining
>> the mapper on that class and view it's uselist property also. I'm not
>> sure how you would find the right relation if there were 2 relations
>> between the classes.
> No, p.backref.prop = p, so it does not work.
>
> However, thanks for suggestion - it gave me a hint to look at all
> backref fields and one-to-one definition.
> If "one to one" is defined this way (my case, it generates MANYTOONE
> relation):
>
> mapper(Parent, parent_table, properties={
> 'child': relation(Child, uselist=False, backref='parent')
> })
>
>
> backref.kwargs will have 'uselist' key set to False. It will also work
> for ONETOMANY case, but won't work with two separate relations.
> A bit hackish solution, I assume, but it works. Some native flag to tell
> that relation is one-to-one will be great to have, though.
uselist=False is the current o2o recipe:
http://www.sqlalchemy.org/docs/05/mappers.html#one-to-one
another flag that does the same thing would be redundant.
>
> Serge.
>
> --
>
> You received this message because you are subscribed to the Google Groups
> "sqlalchemy" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/sqlalchemy?hl=en.
>
>
>
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en.