Skip to content

Commit 4835c7d

Browse files
Fix fingerprint query index failure (#1073)
1 parent abe3c7c commit 4835c7d

File tree

2 files changed

+13
-21
lines changed

2 files changed

+13
-21
lines changed

internal/queries/fingerprint.sql.go

Lines changed: 5 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/queries/sql/fingerprint.sql

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ON CONFLICT (hash, algorithm) DO UPDATE SET hash = EXCLUDED.hash
66
RETURNING *;
77

88
-- name: GetFingerprint :one
9-
SELECT * FROM fingerprints WHERE hash = $1 AND algorithm = $2;
9+
SELECT * FROM fingerprints WHERE (hash, algorithm) = (sqlc.arg(hash)::bigint, sqlc.arg(algorithm)::text);
1010

1111
-- name: SubmittedHashExists :one
1212
SELECT EXISTS(
@@ -35,10 +35,9 @@ DELETE FROM scene_fingerprints WHERE scene_id = $1;
3535
DELETE FROM scene_fingerprints SFP
3636
USING fingerprints FP
3737
WHERE SFP.fingerprint_id = FP.id
38-
AND FP.hash = $1
39-
AND FP.algorithm = $2
40-
AND user_id = $3
41-
AND scene_id = $4;
38+
AND (FP.hash, FP.algorithm) = (sqlc.arg(hash)::bigint, sqlc.arg(algorithm)::text)
39+
AND user_id = sqlc.arg(user_id)
40+
AND scene_id = sqlc.arg(scene_id);
4241

4342
-- name: GetAllSceneFingerprints :many
4443
SELECT f.algorithm, f.hash, sf.duration, sf.created_at, sf.user_id
@@ -74,8 +73,7 @@ WITH to_move AS (
7473
SELECT SFP.fingerprint_id, SFP.user_id
7574
FROM scene_fingerprints SFP
7675
JOIN fingerprints FP ON SFP.fingerprint_id = FP.id
77-
WHERE FP.hash = sqlc.arg(hash)
78-
AND FP.algorithm = sqlc.arg(algorithm)
76+
WHERE (FP.hash, FP.algorithm) = (sqlc.arg(hash)::bigint, sqlc.arg(algorithm)::text)
7977
AND SFP.scene_id = sqlc.arg(source_scene_id)
8078
),
8179
deleted AS (
@@ -87,14 +85,12 @@ UPDATE scene_fingerprints SFP
8785
SET scene_id = sqlc.arg(target_scene_id)
8886
FROM fingerprints FP
8987
WHERE SFP.fingerprint_id = FP.id
90-
AND FP.hash = sqlc.arg(hash)
91-
AND FP.algorithm = sqlc.arg(algorithm)
88+
AND (FP.hash, FP.algorithm) = (sqlc.arg(hash)::bigint, sqlc.arg(algorithm)::text)
9289
AND SFP.scene_id = sqlc.arg(source_scene_id);
9390

9491
-- name: DeleteAllSceneFingerprintSubmissions :execrows
9592
DELETE FROM scene_fingerprints SFP
9693
USING fingerprints FP
9794
WHERE SFP.fingerprint_id = FP.id
98-
AND FP.hash = $1
99-
AND FP.algorithm = $2
100-
AND SFP.scene_id = $3;
95+
AND (FP.hash, FP.algorithm) = (sqlc.arg(hash)::bigint, sqlc.arg(algorithm)::text)
96+
AND SFP.scene_id = sqlc.arg(scene_id);

0 commit comments

Comments
 (0)