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

Error: pq: syntax error at or near "." whilst counting Collaborations without existing user #17485

Closed
frnmst opened this issue Oct 29, 2021 · 5 comments · Fixed by #17487 or #18072
Closed
Labels
Milestone

Comments

@frnmst
Copy link

frnmst commented Oct 29, 2021

Gitea Version

1.15.6

Git Version

git version 2.20.1

Operating System

Debian 10

How are you running Gitea?

using deb [arch=amd64] https://packaging.gitlab.io/gitea buster stable as APT source

Database

PostgreSQL

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Description

I migrated from Gitea 1.15.2 directly to 1.15.6. If I run the following I get the error.

HOME=/var/lib/gitea GITEA_WORK_DIR=/var/lib/gitea /usr/bin/gitea -c /etc/gitea/app.ini doctor --all --fix

[1] Check paths and basic configuration
 - [I] Configuration File Path:    "/etc/gitea/app.ini"
 - [I] Repository Root Path:       "/var/lib/gitea/repos"
 - [I] Data Root Path:             "data"
 - [I] Custom File Root Path:      "/var/lib/gitea/custom"
 - [I] Work directory:             "/var/lib/gitea"
 - [I] Log Root Path:              "/var/log/gitea"
OK
[2] Check if there is garbage storage files
OK
[3] Check Database Version
OK
[4] Check consistency of database
 - [C] Error: pq: syntax error at or near "." whilst counting Collaborations without existing user
ERROR
[5] Check if user with wrong type exist
OK
[6] Check if OpenSSH authorized_keys file is up-to-date
OK

[... continues normally ...]

Anyway, everthing seems to be working fine. The collaboration table in the database is empty.

Screenshots

No response

zeripath added a commit to zeripath/gitea that referenced this issue Oct 29, 2021
CountOrphanedObjects needs to quote the table it is joining with as this table may
be `user`.

Fix go-gitea#17485

Signed-off-by: Andrew Thornton <art27@cantab.net>
zeripath added a commit to zeripath/gitea that referenced this issue Oct 29, 2021
Backport go-gitea#17487

CountOrphanedObjects needs to quote the table it is joining with as this table may
be `user`.

Fix go-gitea#17485

Signed-off-by: Andrew Thornton <art27@cantab.net>
@zeripath zeripath added this to the 1.15.7 milestone Oct 29, 2021
zeripath added a commit that referenced this issue Oct 30, 2021
CountOrphanedObjects needs to quote the table it is joining with as this table may
be `user`.

Fix #17485

Signed-off-by: Andrew Thornton <art27@cantab.net>
6543 pushed a commit that referenced this issue Oct 30, 2021
Backport #17487

CountOrphanedObjects needs to quote the table it is joining with as this table may
be `user`.

Fix #17485

Signed-off-by: Andrew Thornton <art27@cantab.net>
@clarfonthey
Copy link
Contributor

Are you sure that this is fixed? I'm still getting the error even though I'm running 1.15.7, which supposedly has the fix.

@zeripath
Copy link
Contributor

Is it still the same warning exactly?

@zeripath
Copy link
Contributor

zeripath commented Dec 22, 2021

"collaboration", "user", "collaboration.user_id=user.id"),

user needs to be backticked in the query at the end

@zeripath zeripath reopened this Dec 22, 2021
@clarfonthey
Copy link
Contributor

Yeah, unfortunately there's no specific clarification on the error that lets you see what the specific syntax error is, and it shows up as the same. Maybe worth fixing that as well as the underlying issue.

@zeripath
Copy link
Contributor

zeripath commented Dec 22, 2021

Could you apply the following patch and attempt again to see if it solves the problem?

diff --git a/modules/doctor/dbconsistency.go b/modules/doctor/dbconsistency.go
index e5f0c5678..cd34994e1 100644
--- a/modules/doctor/dbconsistency.go
+++ b/modules/doctor/dbconsistency.go
@@ -167,13 +167,13 @@ func checkDBConsistency(logger log.Logger, autofix bool) error {
 			"lfs_lock", "repository", "lfs_lock.repo_id=repository.id"),
 		// find collaborations without users
 		genericOrphanCheck("Collaborations without existing user",
-			"collaboration", "user", "collaboration.user_id=user.id"),
+			"collaboration", "user", "collaboration.user_id=`user`.id"),
 		// find collaborations without repository
 		genericOrphanCheck("Collaborations without existing repository",
 			"collaboration", "repository", "collaboration.repo_id=repository.id"),
 		// find access without users
 		genericOrphanCheck("Access entries without existing user",
-			"access", "user", "access.user_id=user.id"),
+			"access", "user", "access.user_id=`user`.id"),
 		// find access without repository
 		genericOrphanCheck("Access entries without existing repository",
 			"access", "repository", "access.repo_id=repository.id"),

zeripath added a commit to zeripath/gitea that referenced this issue Dec 22, 2021
Although go-gitea#17487 ensured that the table was quoted in the join it missed that the
query part of the check also needed to be quoted.

Fix go-gitea#17485

Signed-off-by: Andrew Thornton <art27@cantab.net>
zeripath added a commit to zeripath/gitea that referenced this issue Dec 22, 2021
)

Backport go-gitea#18072

Although go-gitea#17487 ensured that the table was quoted in the join it missed that the
query part of the check also needed to be quoted.

Fix go-gitea#17485

Signed-off-by: Andrew Thornton <art27@cantab.net>
zeripath added a commit that referenced this issue Dec 22, 2021
…8073)

Backport #18072

Although #17487 ensured that the table was quoted in the join it missed that the
query part of the check also needed to be quoted.

Fix #17485

Signed-off-by: Andrew Thornton <art27@cantab.net>
zeripath added a commit that referenced this issue Dec 22, 2021
Although #17487 ensured that the table was quoted in the join it missed that the
query part of the check also needed to be quoted.

Fix #17485

Signed-off-by: Andrew Thornton <art27@cantab.net>
Chianina pushed a commit to Chianina/gitea that referenced this issue Mar 28, 2022
CountOrphanedObjects needs to quote the table it is joining with as this table may
be `user`.

Fix go-gitea#17485

Signed-off-by: Andrew Thornton <art27@cantab.net>
Chianina pushed a commit to Chianina/gitea that referenced this issue Mar 28, 2022
)

Although go-gitea#17487 ensured that the table was quoted in the join it missed that the
query part of the check also needed to be quoted.

Fix go-gitea#17485

Signed-off-by: Andrew Thornton <art27@cantab.net>
@go-gitea go-gitea locked and limited conversation to collaborators Apr 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
3 participants