Sorry Michael,

there was a typo in my code, due to some wrong copy/paste or search/replace
I guess, I'm afraid.

The error I reported comes up mapping to `TransmLimit` and not `SurfaceRes`
(which is the one already mapped above).

I edited the pastebin:

http://pastebin.com/mjfgPrcB

now with:

'transm_limit': relationship(TransmLimit, single_parent=True,
        uselist=False,
        primaryjoin=and_(
            user_stratigraphies.c.id_prov==provinces.c.id,
            provinces.c.id_cz==transm_limits.c.id_cz,
            user_stratigraphies.c.id_str==stratigraphies.c.id,
            stratigraphies.c.id_tec==tech_elements_classes.c.id,
            tech_elements_classes.c.id_tu==transm_limits.c.id_tu,
            ),
        foreign_keys=(
            user_stratigraphies.c.id_prov,
        ),
    ),

I get the error I reported:

sqlalchemy.exc.ArgumentError: Could not locate any foreign-key-equated,
locally mapped column pairs for primaryjoin condition
'user_stratigraphies.id_prov = provinces.id AND provinces.id_cz =
transm_limits.id_cz AND user_stratigraphies.id_str = stratigraphies.id AND
stratigraphies.id_tec = tech_elements_classes.id AND
tech_elements_classes.id_tu = transm_limits.id_tu' on relationship
ustratatigraphy.transm_limit.  For more relaxed rules on join conditions,
the relationship may be marked as viewonly=True.

Also there's the strange `viewonly=True` behavior that breakes
`UserStratigraphy.surface_res` relationship if uncommented.

Thanks for your patience.
neurino



On Mon, Aug 1, 2011 at 11:14 PM, Michael Bayer <mike...@zzzcomputing.com>wrote:

> 'transm_limit': relationship(SurfaceRes, single_parent=True,
>        #        uselist=False,
>        #        primaryjoin=and_(
>        #            user_stratigraphies.c.id_prov==provinces.c.id,
>        #            provinces.c.id_cz==transm_limits.c.id_cz,
>        #            user_stratigraphies.c.id_str==stratigraphies.c.id,
>        #            stratigraphies.c.id_tec==tech_elements_classes.c.id,
>        #            tech_elements_classes.c.id_tu==transm_limits.c.id_tu,
>        #            ),
>
> this fails because you aren't joining to the table to which SurfaceRes is
> mapped, "surface_res".
>
>
>
> On Aug 1, 2011, at 7:02 AM, neurino wrote:
>
> > I'm trying to get some relationships spanning on multiple tables (4 or
> > 5).
> >
> > While I got the `4 tables` one working on first attempt (I was
> > surpized I could...) I can't get the `5 tables` one to work while the
> > code is almost the same.
> >
> > Moreover with the first relationship if I add adding `viewonly=True`
> > initialization fails.
> >
> > I just need these to get (not even set) some values with convenience
> > of SA attributes.
> >
> > I published a working example on pastebin:
> >
> > http://pastebin.com/RsZ6GCRq
> >
> > I hope someone can sort out this thing, thank you.
> >
> > Greetings
> > neurino
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> "sqlalchemy" group.
> > To post to this group, send email to sqlalchemy@googlegroups.com.
> > To unsubscribe from this group, send email to
> sqlalchemy+unsubscr...@googlegroups.com.
> > 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 sqlalchemy@googlegroups.com.
> To unsubscribe from this group, send email to
> sqlalchemy+unsubscr...@googlegroups.com.
> 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 sqlalchemy@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to