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

gitea doctor doesn't work on mssql #23064

Closed
suntsu42 opened this issue Feb 22, 2023 · 0 comments · Fixed by #23132
Closed

gitea doctor doesn't work on mssql #23064

suntsu42 opened this issue Feb 22, 2023 · 0 comments · Fixed by #23132
Labels

Comments

@suntsu42
Copy link

Description

I'm currently trying to solve an issue where some users don't see repositories on their landing page.
The problem i have is very similar to the one described in #13843

Based on the answers there, i've run the following command:

gitea doctor --run check-db-consistency

This command end with the following error:

[1] Check consistency of database
 - [C] Error: mssql: Incorrect syntax near the keyword 'user'. whilst counting Orphaned Labels without existing repository or organisation
ERROR

I've then traced the queries on the database, and the following query gets executed:

SELECT count(*) FROM [label] WHERE org_id>0 AND org_id NOT IN (SELECT id FROM user)

image

Since user is a keyword in mssql, this is not a valid query.
The query should be written like this:

SELECT count(*) FROM [label] WHERE org_id>0 AND org_id NOT IN (SELECT id FROM [user])

Gitea Version

1.85

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Screenshots

No response

Git Version

No response

Operating System

Windows Server 2022

How are you running Gitea?

I run gittea as a standalone .exe

Database

MSSQL

zeripath added a commit to zeripath/gitea that referenced this issue Feb 24, 2023
Unfortunately xorm's `builder.Select(...).From(...)` does not escape the
table names. This is mostly not a problem but is a problem with the
`user` table.

This PR simply escapes the user table. No other uses of `From("user")`
where found in the codebase so I think this should be all that is
needed.

Fix go-gitea#23064

Signed-off-by: Andrew Thornton <art27@cantab.net>
techknowlogick pushed a commit that referenced this issue Feb 24, 2023
Unfortunately xorm's `builder.Select(...).From(...)` does not escape the
table names. This is mostly not a problem but is a problem with the
`user` table.

This PR simply escapes the user table. No other uses of `From("user")`
where found in the codebase so I think this should be all that is
needed.

Fix #23064

Signed-off-by: Andrew Thornton <art27@cantab.net>
yardenshoham pushed a commit to yardenshoham/gitea that referenced this issue Feb 24, 2023
Unfortunately xorm's `builder.Select(...).From(...)` does not escape the
table names. This is mostly not a problem but is a problem with the
`user` table.

This PR simply escapes the user table. No other uses of `From("user")`
where found in the codebase so I think this should be all that is
needed.

Fix go-gitea#23064

Signed-off-by: Andrew Thornton <art27@cantab.net>
yardenshoham pushed a commit to yardenshoham/gitea that referenced this issue Feb 24, 2023
Unfortunately xorm's `builder.Select(...).From(...)` does not escape the
table names. This is mostly not a problem but is a problem with the
`user` table.

This PR simply escapes the user table. No other uses of `From("user")`
where found in the codebase so I think this should be all that is
needed.

Fix go-gitea#23064

Signed-off-by: Andrew Thornton <art27@cantab.net>
lunny pushed a commit that referenced this issue Feb 25, 2023
Backport #23132

Unfortunately xorm's `builder.Select(...).From(...)` does not escape the
table names. This is mostly not a problem but is a problem with the
`user` table.

This PR simply escapes the user table. No other uses of `From("user")`
where found in the codebase so I think this should be all that is
needed.

Fix #23064

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: zeripath <art27@cantab.net>
lafriks pushed a commit that referenced this issue Feb 25, 2023
Backport #23132

Unfortunately xorm's `builder.Select(...).From(...)` does not escape the
table names. This is mostly not a problem but is a problem with the
`user` table.

This PR simply escapes the user table. No other uses of `From("user")`
where found in the codebase so I think this should be all that is
needed.

Fix #23064

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: zeripath <art27@cantab.net>
@go-gitea go-gitea locked and limited conversation to collaborators May 3, 2023
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.

1 participant