I added distinct() to selectresults as a method and made the unit test
a little clearer (since i dont like relying on the selectresults
"mod")...

        q = sess.query(Department)
        d = SelectResults(q)
        d =
d.join_to('employees').filter(Employee.c.name.startswith('J'))
        d = d.distinct()
        d = d.order_by([desc(Department.c.name)])


On Feb 5, 3:39 pm, [EMAIL PROTECTED] wrote:
> hey i tried this, and looking at the src:
>  - u missed one .split() on the dept2 string of employess
>  - print list(d) then doing d[0] - isn't queryresult supposed to be
> generator, so what is d[0] after wholly iterating it..
>
> Except that d.count() != len(d) in the use_distinct=False case, all
> else seems ok - i do have order_by on both, sizes are ok, order is
> ok...
> rev 2291/2300
>
> ciao
> svil
>
> > Hi again,
>
> > I'm using the SelectResults mod, and I think there may be a bug
> > with the way one-to-many relationships are handled. The attached
> > file should show the problem.
>
> > In the example, I have two mapped classes, Department and Employee,
> > such that a department has many employees. In the 'check' function
> > I am trying to select all the departments which have an employee
> > whose name starts with 'J'. I am also ordering the results by
> > Department name, descending.
>
> > If I pass distinct=False, then the result of the count() is wrong -
> > I assume that is the expected behaviour, and not a bug. However, if
> > I pass distinct=True, the order_by does not appear in the nested
> > ('tbl_row_count') query, so the wrong row is returned.
>
> > In case it makes a difference, I've tested this with revisions 2283
> > and 2300 of the trunk.
>
> > Cheers,
>
> > Simon


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