From 4b1ac9177dc2795499af9ba5345875a4424ebb59 Mon Sep 17 00:00:00 2001 From: Iron_Felix Date: Sat, 22 Nov 2025 08:34:26 +0300 Subject: [PATCH] fix --- modules/backend/queries.sql | 10 ++++++++-- sql/queries.sql.go | 14 ++++++++++---- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/modules/backend/queries.sql b/modules/backend/queries.sql index 9bb7c36..3c5c10e 100644 --- a/modules/backend/queries.sql +++ b/modules/backend/queries.sql @@ -78,7 +78,10 @@ SELECT t.*, i.storage_type::text as title_storage_type, i.image_path as title_image_path, - jsonb_agg(g.tag_name)'[]'::jsonb as tag_names, + COALESCE( + jsonb_agg(g.tag_names) FILTER (WHERE g.tag_names IS NOT NULL), + '[]'::jsonb + ) as tag_names, s.studio_name as studio_name, s.illust_id as studio_illust_id, s.studio_desc as studio_desc, @@ -101,7 +104,10 @@ SELECT t.*, i.storage_type::text as title_storage_type, i.image_path as title_image_path, - jsonb_agg(g.tag_name)'[]'::jsonb as tag_names, + COALESCE( + jsonb_agg(g.tag_names) FILTER (WHERE g.tag_names IS NOT NULL), + '[]'::jsonb + ) as tag_names, s.studio_name as studio_name, s.illust_id as studio_illust_id, s.studio_desc as studio_desc, diff --git a/sql/queries.sql.go b/sql/queries.sql.go index dc8f3f6..7caa7f0 100644 --- a/sql/queries.sql.go +++ b/sql/queries.sql.go @@ -120,7 +120,10 @@ SELECT t.id, t.title_names, t.studio_id, t.poster_id, t.title_status, t.rating, t.rating_count, t.release_year, t.release_season, t.season, t.episodes_aired, t.episodes_all, t.episodes_len, i.storage_type::text as title_storage_type, i.image_path as title_image_path, - jsonb_agg(g.tag_name)'[]'::jsonb as tag_names, + COALESCE( + jsonb_agg(g.tag_names) FILTER (WHERE g.tag_names IS NOT NULL), + '[]'::jsonb + ) as tag_names, s.studio_name as studio_name, s.illust_id as studio_illust_id, s.studio_desc as studio_desc, @@ -155,7 +158,7 @@ type GetTitleByIDRow struct { EpisodesLen []byte `json:"episodes_len"` TitleStorageType string `json:"title_storage_type"` TitleImagePath *string `json:"title_image_path"` - TagNames []byte `json:"tag_names"` + TagNames interface{} `json:"tag_names"` StudioName *string `json:"studio_name"` StudioIllustID *int64 `json:"studio_illust_id"` StudioDesc *string `json:"studio_desc"` @@ -341,7 +344,10 @@ SELECT t.id, t.title_names, t.studio_id, t.poster_id, t.title_status, t.rating, t.rating_count, t.release_year, t.release_season, t.season, t.episodes_aired, t.episodes_all, t.episodes_len, i.storage_type::text as title_storage_type, i.image_path as title_image_path, - jsonb_agg(g.tag_name)'[]'::jsonb as tag_names, + COALESCE( + jsonb_agg(g.tag_names) FILTER (WHERE g.tag_names IS NOT NULL), + '[]'::jsonb + ) as tag_names, s.studio_name as studio_name, s.illust_id as studio_illust_id, s.studio_desc as studio_desc, @@ -482,7 +488,7 @@ type SearchTitlesRow struct { EpisodesLen []byte `json:"episodes_len"` TitleStorageType string `json:"title_storage_type"` TitleImagePath *string `json:"title_image_path"` - TagNames []byte `json:"tag_names"` + TagNames interface{} `json:"tag_names"` StudioName *string `json:"studio_name"` StudioIllustID *int64 `json:"studio_illust_id"` StudioDesc *string `json:"studio_desc"`