fix
This commit is contained in:
parent
4b1ac9177d
commit
d0c3547ef6
4 changed files with 25 additions and 21 deletions
|
|
@ -7,6 +7,7 @@ package sqlc
|
|||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"time"
|
||||
|
||||
"github.com/jackc/pgx/v5/pgtype"
|
||||
|
|
@ -123,7 +124,7 @@ SELECT
|
|||
COALESCE(
|
||||
jsonb_agg(g.tag_names) FILTER (WHERE g.tag_names IS NOT NULL),
|
||||
'[]'::jsonb
|
||||
) as tag_names,
|
||||
)::jsonb as tag_names,
|
||||
s.studio_name as studio_name,
|
||||
s.illust_id as studio_illust_id,
|
||||
s.studio_desc as studio_desc,
|
||||
|
|
@ -144,7 +145,7 @@ GROUP BY
|
|||
|
||||
type GetTitleByIDRow struct {
|
||||
ID int64 `json:"id"`
|
||||
TitleNames []byte `json:"title_names"`
|
||||
TitleNames json.RawMessage `json:"title_names"`
|
||||
StudioID int64 `json:"studio_id"`
|
||||
PosterID *int64 `json:"poster_id"`
|
||||
TitleStatus TitleStatusT `json:"title_status"`
|
||||
|
|
@ -158,7 +159,7 @@ type GetTitleByIDRow struct {
|
|||
EpisodesLen []byte `json:"episodes_len"`
|
||||
TitleStorageType string `json:"title_storage_type"`
|
||||
TitleImagePath *string `json:"title_image_path"`
|
||||
TagNames interface{} `json:"tag_names"`
|
||||
TagNames json.RawMessage `json:"tag_names"`
|
||||
StudioName *string `json:"studio_name"`
|
||||
StudioIllustID *int64 `json:"studio_illust_id"`
|
||||
StudioDesc *string `json:"studio_desc"`
|
||||
|
|
@ -227,15 +228,15 @@ JOIN title_tags as t ON(t.tag_id = g.id)
|
|||
WHERE t.title_id = $1::bigint
|
||||
`
|
||||
|
||||
func (q *Queries) GetTitleTags(ctx context.Context, titleID int64) ([][]byte, error) {
|
||||
func (q *Queries) GetTitleTags(ctx context.Context, titleID int64) ([]json.RawMessage, error) {
|
||||
rows, err := q.db.Query(ctx, getTitleTags, titleID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
items := [][]byte{}
|
||||
items := []json.RawMessage{}
|
||||
for rows.Next() {
|
||||
var tag_names []byte
|
||||
var tag_names json.RawMessage
|
||||
if err := rows.Scan(&tag_names); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
@ -312,7 +313,7 @@ VALUES (
|
|||
RETURNING id, tag_names
|
||||
`
|
||||
|
||||
func (q *Queries) InsertTag(ctx context.Context, tagNames []byte) (Tag, error) {
|
||||
func (q *Queries) InsertTag(ctx context.Context, tagNames json.RawMessage) (Tag, error) {
|
||||
row := q.db.QueryRow(ctx, insertTag, tagNames)
|
||||
var i Tag
|
||||
err := row.Scan(&i.ID, &i.TagNames)
|
||||
|
|
@ -347,7 +348,7 @@ SELECT
|
|||
COALESCE(
|
||||
jsonb_agg(g.tag_names) FILTER (WHERE g.tag_names IS NOT NULL),
|
||||
'[]'::jsonb
|
||||
) as tag_names,
|
||||
)::jsonb as tag_names,
|
||||
s.studio_name as studio_name,
|
||||
s.illust_id as studio_illust_id,
|
||||
s.studio_desc as studio_desc,
|
||||
|
|
@ -474,7 +475,7 @@ type SearchTitlesParams struct {
|
|||
|
||||
type SearchTitlesRow struct {
|
||||
ID int64 `json:"id"`
|
||||
TitleNames []byte `json:"title_names"`
|
||||
TitleNames json.RawMessage `json:"title_names"`
|
||||
StudioID int64 `json:"studio_id"`
|
||||
PosterID *int64 `json:"poster_id"`
|
||||
TitleStatus TitleStatusT `json:"title_status"`
|
||||
|
|
@ -488,7 +489,7 @@ type SearchTitlesRow struct {
|
|||
EpisodesLen []byte `json:"episodes_len"`
|
||||
TitleStorageType string `json:"title_storage_type"`
|
||||
TitleImagePath *string `json:"title_image_path"`
|
||||
TagNames interface{} `json:"tag_names"`
|
||||
TagNames json.RawMessage `json:"tag_names"`
|
||||
StudioName *string `json:"studio_name"`
|
||||
StudioIllustID *int64 `json:"studio_illust_id"`
|
||||
StudioDesc *string `json:"studio_desc"`
|
||||
|
|
@ -607,7 +608,7 @@ type SearchUserTitlesRow struct {
|
|||
ReviewID *int64 `json:"review_id"`
|
||||
Ctime pgtype.Timestamptz `json:"ctime"`
|
||||
ID int64 `json:"id"`
|
||||
TitleNames []byte `json:"title_names"`
|
||||
TitleNames json.RawMessage `json:"title_names"`
|
||||
StudioID int64 `json:"studio_id"`
|
||||
PosterID *int64 `json:"poster_id"`
|
||||
TitleStatus TitleStatusT `json:"title_status"`
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue