I have a table of employees and a table of shifts and I want to write a
single query like this:

select emp.name, shifts.start_time
from employees emp, shifts
where emp.department_id = 99
and emp.id = shifts.employee_id

I can't figure out how to do this with SQLObject.

When I do this:

x = Shift.select(AND(
        Employee.q.departmentID==99,
        Shift.q.employeeID==Employee.q.id))

I get the right shifts, but when I try to display information from the
employee table, then for each row, SQLObject does a single query.

In other words, when I do:

[(sh.employee.name, sh.start_time) for sh in x]

Then for every shift in the query results, I see SQLObject go back to
the database again to get that employee's name.

Is there a better way?

Matt


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to