I would like to generate this query:
SELECT a.pk, aa.response
FROM attendee as "a"
JOIN field as "f" on f.conference_pk = a.conference_pk
LEFT JOIN attendee_answer as "aa" ON aa.field_pk = f.pk
AND aa.attendee_pk = a.pk;
Using the ORM, I came up with:
onclause = and_(
AttendeeAnswer.field_pk==Field.pk, AttendeeAnswer.attendee_pk
== Attendee.pk
)
query = self.session.query(Attendee).join(
Field, Field.conference_pk == Attendee.conference_pk
).outerjoin(
(AttendeeAnswer, onclause)
).add_entity(
AttendeeAnswer
).filter(
Attendee.conference_pk == conference_pk
)
results = query.all()
But this returns separate ORM objects, but in this specific case I would
just like the results in a list containing the data results, rather than
individual ORM objects. Is there a way to do this or should I just pass
my select statement to execute?
--
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.