Thanks! That works, but is the line I quoted just wrong or outdated or what? This is what I'm talking about, under "def join()" http://www.sqlalchemy.org/docs/04/sqlalchemy_orm_query.html#docstrings_sqlalchemy.orm.query_Query
By the way, is 0.4 the recommended version to use for a new project? On Jun 24, 11:52 pm, Kyle Schaffrick <[EMAIL PROTECTED]> wrote: > On Tue, 24 Jun 2008 18:22:49 -0700 (PDT) > > > > bukzor <[EMAIL PROTECTED]> wrote: > > The Query.join() documentations says: > > def join(self, prop, id=None, aliased=False, from_joinpoint=False) > > 'prop' may be one of: > > * a class-mapped attribute, i.e. Houses.rooms > > > What exactly counts as class-mapped? I've set up a ForeignKey in my > > Files table as well as a backref relation in my Projects table, but > > none of these work: > > > print session.query(File).join(Project).filter_by(project='mario', > > tapeout='sa11').one() > > print > > session.query(File).join(Project.files).filter_by(project='mario', > > tapeout='sa11').one() > > print session.query(File).join(Project.id).filter_by(project='mario', > > tapeout='sa11').one() > > print > > session.query(File).join(File.project).filter_by(project='mario', > > tapeout='sa11').one() > > print > > session.query(File).join(File.project_id).filter_by(project='mario', > > tapeout='sa11').one() > > > They all fail with: > > sqlalchemy.exceptions.InvalidRequestError: Mapper 'Mapper|File|files' > > has no property '<sqlalchemy.orm.attributes.InstrumentedAttribute > > object at 0x2a9a283650>' > > > It seems like .join(Project) should 'just work' after the information > > I put in the sytem, but I don't know much... > > > If there's some documentation that makes this clear, feel free to just > > link it. > > If you want more code, let me know what to copy/paste. > > The ORM tutorial [1] is a little more instructive here, what join() > actually wants is a string with the name of the relation you put on (in > this case) File's mapper. > > I'll assume it's something like > > properties = { > ... > 'project': relation(Project), > ...} > > in which case you want join('project'). SA's rationale for doing it this > way is that you can do things like setting up multiple relations from > File to Project, and tweak the parameters on each relation to get > different behavior, without the joins being ambiguous. [2] has an > example of a setup like this. > > > Thanks! > > --Buck > > HTH > -Kyle > > [1]http://sqlalchemy.org/docs/04/ormtutorial.html#datamapping_joins > [2]http://sqlalchemy.org/docs/04 > /mappers.html#advdatamapping_relation_customjoin_multiplejoin --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---