Hello, and sorry if this issue is already covered.
I have a table which makes foreign references to other table, and I need to
make a filter against that table multiple times.

so I have:

q1=session.query(Fuente).outerjoin(Fuente.PPersona,
aliased=True).outerjoin(Fuente.PPersona_como_fuente, aliased=True)

i.e. Fuente makes more than one reference to table Persona, thru the
properties PPersona and PPersona_como_fuente.

until here, it works fine.

Now if I need to construct a filter against Persona, how do I make explicit
that I want to make a condition to a field of Persona
as, for example, Fuente.PPersona.sexo   and not
Fuente.PPersona_como_fuente.sexo     ?

lets say:

q2=q1.filter(Persona.sexo == '111')

I get an ambiguous sql expression, like this:

SELECT
fuente.id AS fuente_id, fuente.caso_id AS fuente_caso_id
FROM fuente
           LEFT OUTER JOIN persona AS persona_1 ON persona_1.id =
fuente.persona_referenciada_id
           LEFT OUTER JOIN persona AS persona_2 ON persona_2.id =
fuente.persona_fuente_id
WHERE
           persona_2.sexo = %(persona_sexo_1)s
ORDER BY fuente.id

Until now, the only solution I found was to make an alias to the 'persona'
table, and then write new definitions for alternate 'Persona' object class
and PersonaMapper.
That way it works fine, but if I work with that table from a complex set of
references, it becomes a nightmare of copies....

BTW, in spanish, sexo (also) means gender ;)

So thanks in advance for any magic solution (or reference)

Adolfo

-- 
Adolfo Dunayevich

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to [email protected]
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