-
Notifications
You must be signed in to change notification settings - Fork 242
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
without_distinct() and first() does not work right together. #92
Comments
Oops, I forgot that |
Now this should work: a = select(t.field for t in T).without_distinct().order_by(...).first()
a = select(t.field for t in T).order_by(...).without_distinct().first() But this should not: a = select(t.field for t in T).order_by(...).first().without_distinct() because the result of The code that you wrote initially was incorrect: a = select(t.field for t in T).order_by(...)
a.without_distinct()
a = a.first() This doesn't work as expected, because the result of query = select(t.field for t in T).order_by(...)
query = query.without_distinct()
obj = query.first() But note that I just fixed #90 as well, so the explicit call of obj = select(t.field for t in T).order_by(...).first() with the same effect. |
Huge thanks for detailed description |
Just leave it here:
generates:
|
Are you updated Pony from GitHub? It works just fine for me: >>> from pony.orm.examples.presentation import *
>>> query = select(s for s in Student).order_by(Student.name)
>>> query = query.without_distinct()
>>> obj = query.first()
GET NEW CONNECTION
SWITCH TO AUTOCOMMIT MODE
SELECT "s"."id", "s"."name", "s"."dob", "s"."tel", "s"."gpa", "s"."group"
FROM "Student" "s"
ORDER BY "s"."name"
LIMIT 1
>>> obj
Student[3] |
I mean that I cannot use |
Probably I was not clear enough, the behavior I described is new behavior which I just committed to github. Before the fix |
working code:
Not working codes:
a = select(t.field for t in T).without_distinct().order_by(...).first()
a = select(t.field for t in T).order_by(...).without_distinct().first()
a = select(t.field for t in T).order_by(...).first().without_distinct()
The text was updated successfully, but these errors were encountered: