gitea doctor doesn't work on mssql #10320

Closed
opened 2025-11-02 09:04:13 -06:00 by GiteaMirror · 0 comments
Owner

Originally created by @suntsu42 on GitHub (Feb 22, 2023).

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 https://github.com/go-gitea/gitea/issues/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

Originally created by @suntsu42 on GitHub (Feb 22, 2023). ### 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 https://github.com/go-gitea/gitea/issues/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: ```sql SELECT count(*) FROM [label] WHERE org_id>0 AND org_id NOT IN (SELECT id FROM user) ``` ![image](https://user-images.githubusercontent.com/1768336/220542239-b2b9452e-f5a4-4d96-a60b-3d5915fb0d34.png) Since user is a keyword in mssql, this is not a valid query. The query should be written like this: ```sql 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
GiteaMirror added the type/bug label 2025-11-02 09:04:13 -06:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#10320