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

[mssql] Pull Request Database Issue #5458

Closed
2 of 7 tasks
Cellebyte opened this issue Dec 4, 2018 · 5 comments · Fixed by #5502
Closed
2 of 7 tasks

[mssql] Pull Request Database Issue #5458

Cellebyte opened this issue Dec 4, 2018 · 5 comments · Fixed by #5502
Labels
Milestone

Comments

@Cellebyte
Copy link

Cellebyte commented Dec 4, 2018

  • Gitea version (or commit ref): 20c54f8
  • Git version: Docker Container
  • Operating system: Docker Container
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • Not relevant
  • Log gist:

Description

[...outers/repo/issue.go:835 ViewIssue()] [E] GetReviewersByPullID: mssql: Column 'user.lower_name' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.

Create a pull request.
If i want to look at my pull requests i get the following issue 500 ServerError.
1.6.0 does not have this issue.

@Cellebyte
Copy link
Author

This bug occurs in the current master branch.

@chdxD1
Copy link
Contributor

chdxD1 commented Dec 7, 2018

I have written the following query which works in SQL Server Management Studio. It uses a subquery and seems to return all results needed for the GetReviewersByPullID function to work. However I do not know how to write subqueries with xorm. I do not know whether this query works in MySQL or PostgreSQL.

SELECT [user].*, review.type, review.review_updated_unix FROM (SELECT review.id, review.type, review.reviewer_id, max(review.updated_unix) as review_updated_unix FROM review WHERE review.issue_id=4 AND (review.type = 1 OR review.type = 3) GROUP BY review.id, review.type, review.reviewer_id) as review INNER JOIN [user] ON review.reviewer_id = [user].id ORDER BY review_updated_unix DESC;

@lunny
Copy link
Member

lunny commented Dec 8, 2018

@chdxD1 You can do that using xorm

if db == mssql {
x.SQL(sql).Find(&reviews)
}

Could you send a PR?

@Cellebyte
Copy link
Author

@lunny , @chdxD1 and me tried to implement it with the xorm.builder because it was looking like to have subquery functionality, but the version used by gitea is not the current one. So we have give up after a short time.

if db == mssql { x.SQL(sql).Find(&reviews) }

@lunny can you give an example how the sql variable should look like?

@techknowlogick techknowlogick modified the milestones: 1.6.1, 1.6.2 Dec 9, 2018
@lunny
Copy link
Member

lunny commented Dec 9, 2018

@Cellebyte @chdxD1 please confirm #5502 fixed this.

@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants