the "non-distinct" parts of this test fail on postgres, because its
not doing the nesting thing:
sqlalchemy.exceptions.SQLError: (ProgrammingError) column
"departments.name" must appear in the GROUP BY clause or be used in an
aggregate function
'SELECT count(departments.department_id) \nFROM departments,
employees \nWHERE departments.department_id = employees.department_id
AND employees.name LIKE %(employees_name)s ORDER BY departments.name
DESC' {'employees_name': 'J%'}
generally, the combination youre doing here just barely works. if you
really want to count from a very specific query, you should be
counting from the query itself, not using the ORM.
for the order by getting removed during the select, that seemed to be
an optimization that got stuck in there and since this is a really
fringe use case its never come up, so i removed it and added your test
case (only with distinct=True) in rev 2301.
On Feb 5, 12:46 pm, "King Simon-NFHD78" <[EMAIL PROTECTED]>
wrote:
> 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
>
> one_to_many_test.py
> 3KDownload
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---