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

Update xorm #26049

Closed
wants to merge 3 commits into from
Closed

Update xorm #26049

wants to merge 3 commits into from

Conversation

KN4CK3R
Copy link
Member

@KN4CK3R KN4CK3R commented Jul 21, 2023

Noticed in #25613 that the new xorm version does work with Gitea. Created this PR to keep the other one clean.

The method with the error is models/unittest.GetCount changed in #24963. This method generates a query like

SELECT  count(*) FROM "gtestschema"."user" WHERE (type = 0) ORDER BY id

which is invalid for pgsql and mssql:
ERROR: column "user.id" must appear in the GROUP BY clause or be used in an aggregate function
The error message is a bit strange but for COUNT the order should be irrelevant.
The old xorm version generates the query without ORDER BY

SELECT count(*) FROM "gtestschema"."user" WHERE (type = 0)

@lunny fyi

@KN4CK3R KN4CK3R added dependencies skip-changelog This PR is irrelevant for the (next) changelog, for example bug fixes for unreleased features. labels Jul 21, 2023
@KN4CK3R KN4CK3R added this to the 1.21.0 milestone Jul 21, 2023
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Jul 21, 2023
@pull-request-size pull-request-size bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jul 21, 2023
@lunny
Copy link
Member

lunny commented Jul 22, 2023

Yes. It's a break change of xorm new version. Previously, count with order by will ignore the order by statement automatically. But the new xorm version will not ignore it automatically. Users should handle themselves.

For Gitea, when do count, order by should not be appended.

@lunny
Copy link
Member

lunny commented Jul 22, 2023

Should I revert back the change to ignore order by when it's counting?

@KN4CK3R
Copy link
Member Author

KN4CK3R commented Jul 22, 2023

No, I think it's fine if we need to write correct queries. But how does it work with FindAndCount. The find part should use the order and the count part should not. If xorm does ignore it in this case it's inconsistent handling which may be bad too.

@lunny
Copy link
Member

lunny commented Jul 23, 2023

No, I think it's fine if we need to write correct queries. But how does it work with FindAndCount. The find part should use the order and the count part should not. If xorm does ignore it in this case it's inconsistent handling which may be bad too.

Yes, I have thought of that. And that's why I think maybe it's need to be reverted to original logic.

@KN4CK3R
Copy link
Member Author

KN4CK3R commented Jul 24, 2023

Yes, then the old logic may be better.

@lunny
Copy link
Member

lunny commented Jul 24, 2023

Yes, then the old logic may be better.

Created a new PR to try to fix it https://gitea.com/xorm/xorm/pulls/2307

@KN4CK3R KN4CK3R mentioned this pull request Jul 25, 2023
@lunny
Copy link
Member

lunny commented Jul 25, 2023

@KN4CK3R
Copy link
Member Author

KN4CK3R commented Jul 25, 2023

Seems worse now?

@lunny
Copy link
Member

lunny commented Jul 25, 2023

Seems worse now?

I found this is a bug of Gitea's test because Gitea use an empty string as OrderBy's parameter.

@lunny
Copy link
Member

lunny commented Jul 25, 2023

This could be replaced by #26128

@KN4CK3R KN4CK3R closed this Jul 25, 2023
@GiteaBot GiteaBot removed this from the 1.21.0 milestone Jul 25, 2023
@KN4CK3R KN4CK3R deleted the update-xorm branch July 25, 2023 20:01
@go-gitea go-gitea locked as resolved and limited conversation to collaborators Oct 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. skip-changelog This PR is irrelevant for the (next) changelog, for example bug fixes for unreleased features.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants