K, seems that I've found the root cause:

When you are making the join from query, the syntax is:

app.session.query(Sak).join(Sak.prosjektid).filter(....

where Sak.prosjektid is the relation property of the Sak class

or you can specify the target in the tuples form:

app.session.query(Sak).join((Prosjekt,Sak.prosjekt)), where
(Prosjekt,Sak.prosjekt) - is the tuple with what you join (first) and
how you join (second value)

when you are using commas inside this join, it thinks of the multiple
join statements, so it interprets your

.join(Prosjekt,Sak.prosjektid) as 2 joins requirements and fails

anyway, here is the complete example that works,


tables = {}

tables['prosjekt'] = Table('prosjekt', metadata,
                    Column('prosjektid', Integer, primary_key=True),
                    Column('p_prosjektid', Integer,
ForeignKey('prosjekt.prosjektid')),
                    Column('kundeid', Integer),
                    )


tables['sak'] = Table('sak', metadata,
                      Column('saksnr', Integer, primary_key = True),
                      Column('prosjektid', Integer,
ForeignKey('prosjekt.prosjektid')),
                    )

metadata.create_all()
mappers = {}

class Prosjekt(object):pass
class Sak(object):pass

mappers['prosjekt'] = mapper(Prosjekt, tables['prosjekt'],
            properties = {
            'sak': relation(Sak),
            'p_prosjekt':
relation(Prosjekt,remote_side=[tables['prosjekt'].c.prosjektid])
            })

mappers['sak'] = mapper(Sak, tables['sak'],
            properties = {
            'prosjekt': relation(Prosjekt),
            })

objects =
app.session.query(Sak).join(Sak.prosjekt).filter(Prosjekt.kundeid==15000032).all()

#or

objects =
app.session.query(Sak).join((Prosjekt,Sak.prosjekt)).filter(Prosjekt.kundeid==15000032).all()


On 24 сент, 12:45, olavgg <[EMAIL PROTECTED]> wrote:
> Thank you for your answer,
>
> I did as you said but still returns the same error:
> InvalidRequestError: Mapper 'Mapper|Sak|sak' has no property '<class
> 'Products.TikkTakk.model.Prosjekt.Prosjekt'>'
--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to