Mike, I totally appreciate the help, but it's just not working, for me.
I feel like you've given tons of time on trying to fix this, so if anyone
else wants to step in to hit me with the clue stick, that would be delightful.


More details

db's tried:  postgres, sqlite
sqlalchemy version:   0.5.5 on 64-bit Centos

----------------------
connstring='postgres:///test_a'
def demo():
    session.query(Route).delete()
    for t,h,ts,s in samples :
        session.add(Route(target=t,hop_id=h,ts=ts,startpoint=s))

    session.flush()
    session.commit()
    sq = 
session.query(Route.ts,Route.startpoint,Route.target,func.max(Route.hop_id).label('max_hop'))\
        .group_by(Route.ts,Route.startpoint,Route.target).subquery()
    q = session.query(Route,sq.c.max_hop).join(sq,sq.c.max_hop==Route.hop_id)
    q.all()
-----------------------

Which gives:

ArgumentError: Can't find any foreign key relationships between
'route' and '%(47624668442128 anon)s'

All the other code is as in the first email.  I'm not sure what's
supposed to be happening,
but something clearly isn't right, and I'm clearly having some core model
grokking fail.

In addtion:

>>> print join(Route,sq, Route.hop_id==sq.c.max_hop)
<class '__main__.Route'> JOIN (SELECT route.ts AS ts, route.startpoint
AS startpoint, route.target AS target, max(route.hop_id) AS max_hop
FROM route GROUP BY route.ts, route.startpoint, route.target) AS
anon_1 ON route.hop_id = anon_1.max_hop

This doesn't seem to connect any of the other parts, other than the hop id.



On Thu, Jul 23, 2009 at 8:13 PM, Michael Bayer<mike...@zzzcomputing.com> wrote:
>
>
> On Jul 23, 2009, at 8:43 PM, Gregg Lind wrote:
>
>>
>> Hm.  I appreciate the help, but something is clearly still failing
>> here.
>>
>>> session.query(Route,*sq.c).join(sq.c.max_hop)
>> ArgumentError: Can't find any foreign key relationships between
>> 'route' and 'max_hop'
>>
>> Maybe the filter based solution is just fine here :)
>
> that's not the call sig for query.join() .   if youre dealing with SQL
> expression components, its join((selectable, onclause), ... ), so here
> join((sq, sq.c.max_hop==Route.hop)) .
>
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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