fix
This commit is contained in:
parent
4b1ac9177d
commit
d0c3547ef6
4 changed files with 25 additions and 21 deletions
|
|
@ -81,7 +81,7 @@ SELECT
|
||||||
COALESCE(
|
COALESCE(
|
||||||
jsonb_agg(g.tag_names) FILTER (WHERE g.tag_names IS NOT NULL),
|
jsonb_agg(g.tag_names) FILTER (WHERE g.tag_names IS NOT NULL),
|
||||||
'[]'::jsonb
|
'[]'::jsonb
|
||||||
) as tag_names,
|
)::jsonb as tag_names,
|
||||||
s.studio_name as studio_name,
|
s.studio_name as studio_name,
|
||||||
s.illust_id as studio_illust_id,
|
s.illust_id as studio_illust_id,
|
||||||
s.studio_desc as studio_desc,
|
s.studio_desc as studio_desc,
|
||||||
|
|
@ -107,7 +107,7 @@ SELECT
|
||||||
COALESCE(
|
COALESCE(
|
||||||
jsonb_agg(g.tag_names) FILTER (WHERE g.tag_names IS NOT NULL),
|
jsonb_agg(g.tag_names) FILTER (WHERE g.tag_names IS NOT NULL),
|
||||||
'[]'::jsonb
|
'[]'::jsonb
|
||||||
) as tag_names,
|
)::jsonb as tag_names,
|
||||||
s.studio_name as studio_name,
|
s.studio_name as studio_name,
|
||||||
s.illust_id as studio_illust_id,
|
s.illust_id as studio_illust_id,
|
||||||
s.studio_desc as studio_desc,
|
s.studio_desc as studio_desc,
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ package sqlc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql/driver"
|
"database/sql/driver"
|
||||||
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
|
@ -223,11 +224,11 @@ type ReviewImage struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type Signal struct {
|
type Signal struct {
|
||||||
ID int64 `json:"id"`
|
ID int64 `json:"id"`
|
||||||
TitleID *int64 `json:"title_id"`
|
TitleID *int64 `json:"title_id"`
|
||||||
RawData []byte `json:"raw_data"`
|
RawData json.RawMessage `json:"raw_data"`
|
||||||
ProviderID int64 `json:"provider_id"`
|
ProviderID int64 `json:"provider_id"`
|
||||||
Pending bool `json:"pending"`
|
Pending bool `json:"pending"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Studio struct {
|
type Studio struct {
|
||||||
|
|
@ -238,13 +239,13 @@ type Studio struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type Tag struct {
|
type Tag struct {
|
||||||
ID int64 `json:"id"`
|
ID int64 `json:"id"`
|
||||||
TagNames []byte `json:"tag_names"`
|
TagNames json.RawMessage `json:"tag_names"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Title struct {
|
type Title struct {
|
||||||
ID int64 `json:"id"`
|
ID int64 `json:"id"`
|
||||||
TitleNames []byte `json:"title_names"`
|
TitleNames json.RawMessage `json:"title_names"`
|
||||||
StudioID int64 `json:"studio_id"`
|
StudioID int64 `json:"studio_id"`
|
||||||
PosterID *int64 `json:"poster_id"`
|
PosterID *int64 `json:"poster_id"`
|
||||||
TitleStatus TitleStatusT `json:"title_status"`
|
TitleStatus TitleStatusT `json:"title_status"`
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ package sqlc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/json"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/jackc/pgx/v5/pgtype"
|
"github.com/jackc/pgx/v5/pgtype"
|
||||||
|
|
@ -123,7 +124,7 @@ SELECT
|
||||||
COALESCE(
|
COALESCE(
|
||||||
jsonb_agg(g.tag_names) FILTER (WHERE g.tag_names IS NOT NULL),
|
jsonb_agg(g.tag_names) FILTER (WHERE g.tag_names IS NOT NULL),
|
||||||
'[]'::jsonb
|
'[]'::jsonb
|
||||||
) as tag_names,
|
)::jsonb as tag_names,
|
||||||
s.studio_name as studio_name,
|
s.studio_name as studio_name,
|
||||||
s.illust_id as studio_illust_id,
|
s.illust_id as studio_illust_id,
|
||||||
s.studio_desc as studio_desc,
|
s.studio_desc as studio_desc,
|
||||||
|
|
@ -144,7 +145,7 @@ GROUP BY
|
||||||
|
|
||||||
type GetTitleByIDRow struct {
|
type GetTitleByIDRow struct {
|
||||||
ID int64 `json:"id"`
|
ID int64 `json:"id"`
|
||||||
TitleNames []byte `json:"title_names"`
|
TitleNames json.RawMessage `json:"title_names"`
|
||||||
StudioID int64 `json:"studio_id"`
|
StudioID int64 `json:"studio_id"`
|
||||||
PosterID *int64 `json:"poster_id"`
|
PosterID *int64 `json:"poster_id"`
|
||||||
TitleStatus TitleStatusT `json:"title_status"`
|
TitleStatus TitleStatusT `json:"title_status"`
|
||||||
|
|
@ -158,7 +159,7 @@ type GetTitleByIDRow struct {
|
||||||
EpisodesLen []byte `json:"episodes_len"`
|
EpisodesLen []byte `json:"episodes_len"`
|
||||||
TitleStorageType string `json:"title_storage_type"`
|
TitleStorageType string `json:"title_storage_type"`
|
||||||
TitleImagePath *string `json:"title_image_path"`
|
TitleImagePath *string `json:"title_image_path"`
|
||||||
TagNames interface{} `json:"tag_names"`
|
TagNames json.RawMessage `json:"tag_names"`
|
||||||
StudioName *string `json:"studio_name"`
|
StudioName *string `json:"studio_name"`
|
||||||
StudioIllustID *int64 `json:"studio_illust_id"`
|
StudioIllustID *int64 `json:"studio_illust_id"`
|
||||||
StudioDesc *string `json:"studio_desc"`
|
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
|
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)
|
rows, err := q.db.Query(ctx, getTitleTags, titleID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
defer rows.Close()
|
defer rows.Close()
|
||||||
items := [][]byte{}
|
items := []json.RawMessage{}
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
var tag_names []byte
|
var tag_names json.RawMessage
|
||||||
if err := rows.Scan(&tag_names); err != nil {
|
if err := rows.Scan(&tag_names); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
@ -312,7 +313,7 @@ VALUES (
|
||||||
RETURNING id, tag_names
|
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)
|
row := q.db.QueryRow(ctx, insertTag, tagNames)
|
||||||
var i Tag
|
var i Tag
|
||||||
err := row.Scan(&i.ID, &i.TagNames)
|
err := row.Scan(&i.ID, &i.TagNames)
|
||||||
|
|
@ -347,7 +348,7 @@ SELECT
|
||||||
COALESCE(
|
COALESCE(
|
||||||
jsonb_agg(g.tag_names) FILTER (WHERE g.tag_names IS NOT NULL),
|
jsonb_agg(g.tag_names) FILTER (WHERE g.tag_names IS NOT NULL),
|
||||||
'[]'::jsonb
|
'[]'::jsonb
|
||||||
) as tag_names,
|
)::jsonb as tag_names,
|
||||||
s.studio_name as studio_name,
|
s.studio_name as studio_name,
|
||||||
s.illust_id as studio_illust_id,
|
s.illust_id as studio_illust_id,
|
||||||
s.studio_desc as studio_desc,
|
s.studio_desc as studio_desc,
|
||||||
|
|
@ -474,7 +475,7 @@ type SearchTitlesParams struct {
|
||||||
|
|
||||||
type SearchTitlesRow struct {
|
type SearchTitlesRow struct {
|
||||||
ID int64 `json:"id"`
|
ID int64 `json:"id"`
|
||||||
TitleNames []byte `json:"title_names"`
|
TitleNames json.RawMessage `json:"title_names"`
|
||||||
StudioID int64 `json:"studio_id"`
|
StudioID int64 `json:"studio_id"`
|
||||||
PosterID *int64 `json:"poster_id"`
|
PosterID *int64 `json:"poster_id"`
|
||||||
TitleStatus TitleStatusT `json:"title_status"`
|
TitleStatus TitleStatusT `json:"title_status"`
|
||||||
|
|
@ -488,7 +489,7 @@ type SearchTitlesRow struct {
|
||||||
EpisodesLen []byte `json:"episodes_len"`
|
EpisodesLen []byte `json:"episodes_len"`
|
||||||
TitleStorageType string `json:"title_storage_type"`
|
TitleStorageType string `json:"title_storage_type"`
|
||||||
TitleImagePath *string `json:"title_image_path"`
|
TitleImagePath *string `json:"title_image_path"`
|
||||||
TagNames interface{} `json:"tag_names"`
|
TagNames json.RawMessage `json:"tag_names"`
|
||||||
StudioName *string `json:"studio_name"`
|
StudioName *string `json:"studio_name"`
|
||||||
StudioIllustID *int64 `json:"studio_illust_id"`
|
StudioIllustID *int64 `json:"studio_illust_id"`
|
||||||
StudioDesc *string `json:"studio_desc"`
|
StudioDesc *string `json:"studio_desc"`
|
||||||
|
|
@ -607,7 +608,7 @@ type SearchUserTitlesRow struct {
|
||||||
ReviewID *int64 `json:"review_id"`
|
ReviewID *int64 `json:"review_id"`
|
||||||
Ctime pgtype.Timestamptz `json:"ctime"`
|
Ctime pgtype.Timestamptz `json:"ctime"`
|
||||||
ID int64 `json:"id"`
|
ID int64 `json:"id"`
|
||||||
TitleNames []byte `json:"title_names"`
|
TitleNames json.RawMessage `json:"title_names"`
|
||||||
StudioID int64 `json:"studio_id"`
|
StudioID int64 `json:"studio_id"`
|
||||||
PosterID *int64 `json:"poster_id"`
|
PosterID *int64 `json:"poster_id"`
|
||||||
TitleStatus TitleStatusT `json:"title_status"`
|
TitleStatus TitleStatusT `json:"title_status"`
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,8 @@ sql:
|
||||||
emit_pointers_for_null_types: true
|
emit_pointers_for_null_types: true
|
||||||
emit_empty_slices: true #slices returned by :many queries will be empty instead of nil
|
emit_empty_slices: true #slices returned by :many queries will be empty instead of nil
|
||||||
overrides:
|
overrides:
|
||||||
|
- db_type: "jsonb"
|
||||||
|
go_type: "encoding/json.RawMessage"
|
||||||
- db_type: "uuid"
|
- db_type: "uuid"
|
||||||
nullable: false
|
nullable: false
|
||||||
go_type:
|
go_type:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue