Skip to content
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

feat: do not add a group by clause to O2O-edges for order by neighbor… #3943

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

michaelcaulley
Copy link
Contributor

… terms

this prevents issues with databases that require all selected terms be included in the group by clause. the group by clause is not required if the relationship is O2O, because only one row will be returned if we join on fks.

… terms

this prevents issues with databases that require all selected terms be included
in the group by clause. the group by clause is not required if the relationship
is O2O, because only one row will be returned if we join on fks.
@michaelcaulley
Copy link
Contributor Author

@giautm can you help review this change?

GroupBy(toT.C(s.Edge.Columns[0]))
From(toT)
if s.Edge.Rel != O2O {
join = join.GroupBy(toT.C(s.Edge.Columns[0]))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That’s true if the edge is unique, not only o2o.

Also, please add/update tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@a8m Do you have ideas for tests? It looks like there is already a test that covers ordering by a unique edge field, but all the tests use sqlite, and therefore this specific test passed both before and after this change. This change is only to generate valid sql in other databases too, such as PostgreSQL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants