and maybe related:
 def query_by_id( klas, idname, oid, .....):
     q = session.query( klas).filter_by( **{idname: oid})
     # filter by atype for concrete
     m = class_mapper( klas)
     concrete = bool( m.with_polymorphic[1] )
     if concrete: q= q.filter( m.polymorphic_on == klas.__name__)
     return q.all()

generates a query like 

SELECT pu_a.*
FROM (SELECT A.* FROM "A" 
 UNION ALL
 SELECT C.* FROM "C") 
AS pu_a,
(SELECT A.* FROM "A" 
 UNION ALL 
 SELECT C.* FROM "C") 
AS pu_a 
WHERE pu_a.db_id = ? AND pu_a.atype = ?

with repeated union twice in the FROM, and error thereof. 
Somehow the mapper.polymorphic_on is not recognized as already being 
there and pulls the union once more?
if there's no q.filter( m.polymorphic_on == klas.__name__), no errors 
(but returns multiple objects).

this on latest trunk.

svil

On Wednesday 03 December 2008 19:29:31 Michael Bayer wrote:
> it needed some more work.  the final version of this fix is in
> r5412.
>
> On Dec 3, 2008, at 10:49 AM, Gaetan de Menten wrote:
> > On Wed, Dec 3, 2008 at 16:04, Michael Bayer
> >
> > <[EMAIL PROTECTED]> wrote:
> >> this ones big, i can handle it.   the attached patch makes your
> >> case work, but the problem represented here still makes itself
> >> apparent in other ways and I havent strength tested this patch. 
> >>  you might want to see if this patch works in all of your test
> >> cases.
> >
> > FWIW, my (only) "more complete" test involving polymorphic
> > concrete inheritance passes too (and produces correct SQL).
> > Your patch seem fine and doesn't seem to break unrelated tests.
> >
> > Thanks for the quick reaction time, as usual.
> > --
> > Gaƫtan de Menten
> > http://openhex.org
>
> 


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