fix: bad types from sql

This commit is contained in:
Iron_Felix 2025-11-25 03:55:23 +03:00
parent 4c7d03cddc
commit 673ce48fac
5 changed files with 91 additions and 57 deletions

View file

@ -114,7 +114,7 @@ const getTitleByID = `-- name: GetTitleByID :one
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.storage_type as title_storage_type,
i.image_path as title_image_path,
COALESCE(
jsonb_agg(g.tag_names) FILTER (WHERE g.tag_names IS NOT NULL),
@ -123,7 +123,7 @@ SELECT
s.studio_name as studio_name,
s.illust_id as studio_illust_id,
s.studio_desc as studio_desc,
si.storage_type::text as studio_storage_type,
si.storage_type as studio_storage_type,
si.image_path as studio_image_path
FROM titles as t
@ -152,13 +152,13 @@ type GetTitleByIDRow struct {
EpisodesAired *int32 `json:"episodes_aired"`
EpisodesAll *int32 `json:"episodes_all"`
EpisodesLen []byte `json:"episodes_len"`
TitleStorageType string `json:"title_storage_type"`
TitleStorageType *StorageTypeT `json:"title_storage_type"`
TitleImagePath *string `json:"title_image_path"`
TagNames json.RawMessage `json:"tag_names"`
StudioName *string `json:"studio_name"`
StudioIllustID *int64 `json:"studio_illust_id"`
StudioDesc *string `json:"studio_desc"`
StudioStorageType string `json:"studio_storage_type"`
StudioStorageType *StorageTypeT `json:"studio_storage_type"`
StudioImagePath *string `json:"studio_image_path"`
}
@ -415,7 +415,7 @@ SELECT
t.season as season,
t.episodes_aired as episodes_aired,
t.episodes_all as episodes_all,
i.storage_type::text as title_storage_type,
i.storage_type as title_storage_type,
i.image_path as title_image_path,
COALESCE(
jsonb_agg(g.tag_names) FILTER (WHERE g.tag_names IS NOT NULL),
@ -555,7 +555,7 @@ type SearchTitlesRow struct {
Season *int32 `json:"season"`
EpisodesAired *int32 `json:"episodes_aired"`
EpisodesAll *int32 `json:"episodes_all"`
TitleStorageType string `json:"title_storage_type"`
TitleStorageType *StorageTypeT `json:"title_storage_type"`
TitleImagePath *string `json:"title_image_path"`
TagNames json.RawMessage `json:"tag_names"`
StudioName *string `json:"studio_name"`
@ -628,7 +628,7 @@ SELECT
u.rate as user_rate,
u.review_id as review_id,
u.ctime as user_ctime,
i.storage_type::text as title_storage_type,
i.storage_type as title_storage_type,
i.image_path as title_image_path,
COALESCE(
jsonb_agg(g.tag_names) FILTER (WHERE g.tag_names IS NOT NULL),
@ -719,7 +719,7 @@ WHERE
$8::usertitle_status_t[] IS NULL
OR array_length($8::usertitle_status_t[], 1) IS NULL
OR array_length($8::usertitle_status_t[], 1) = 0
OR t.title_status = ANY($8::usertitle_status_t[])
OR u.status = ANY($8::usertitle_status_t[])
)
AND ($9::int IS NULL OR u.rate >= $9::int)
AND ($10::float IS NULL OR t.rating >= $10::float)
@ -785,7 +785,7 @@ type SearchUserTitlesRow struct {
UserRate *int32 `json:"user_rate"`
ReviewID *int64 `json:"review_id"`
UserCtime time.Time `json:"user_ctime"`
TitleStorageType string `json:"title_storage_type"`
TitleStorageType *StorageTypeT `json:"title_storage_type"`
TitleImagePath *string `json:"title_image_path"`
TagNames json.RawMessage `json:"tag_names"`
StudioName *string `json:"studio_name"`

View file

@ -14,8 +14,11 @@ sql:
emit_pointers_for_null_types: true
emit_empty_slices: true #slices returned by :many queries will be empty instead of nil
overrides:
- column: "titles.title_storage_type"
go_type: "*string"
- db_type: "storage_type_t"
nullable: true
go_type:
type: "StorageTypeT"
pointer: true
- db_type: "jsonb"
go_type: "encoding/json.RawMessage"
- db_type: "uuid"