Extend GET_CATEGORY_ID_BY_HASH to resolve categorypic hashes directly

This commit is contained in:
seb
2026-08-03 07:59:09 +02:00
parent 6128fc59fd
commit b3ef24f34a

View File

@@ -9,11 +9,21 @@ VALUES (
`;
export const GET_CATEGORY_ID_BY_HASH = `
SELECT TOP 1 ca.category_id AS categoryId
FROM pic p
INNER JOIN articlepic ap ON ap.pic_id = p.id
INNER JOIN categoryarticle ca ON ca.article_id = ap.article_id
WHERE p.hash = @hash
SELECT TOP 1 categoryId
FROM (
SELECT ca.category_id AS categoryId
FROM pic p
INNER JOIN articlepic ap ON ap.pic_id = p.id
INNER JOIN categoryarticle ca ON ca.article_id = ap.article_id
WHERE p.hash = @hash
UNION
SELECT cp.category_id AS categoryId
FROM pic p
INNER JOIN categorypic cp ON cp.pic_id = p.id
WHERE p.hash = @hash
) AS combined
`;
export const GET_FULL_BY_HASH = `