Merge branch 'dev' into dev-ars

This commit is contained in:
Iron_Felix 2025-11-22 08:51:13 +03:00
commit b400f22844
5 changed files with 25 additions and 21 deletions

View file

@ -267,7 +267,7 @@ func (s Server) GetTitles(ctx context.Context, request oapi.GetTitlesRequestObje
if request.Params.Sort != nil {
switch string(*request.Params.Sort) {
case "year":
tmp := fmt.Sprint("%d", *t.ReleaseYear)
tmp := fmt.Sprint(*t.ReleaseYear)
new_cursor.Param = &tmp
case "rating":
tmp := strconv.FormatFloat(*t.Rating, 'f', -1, 64)

View file

@ -81,7 +81,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,
@ -107,7 +107,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,

View file

@ -6,6 +6,7 @@ package sqlc
import (
"database/sql/driver"
"encoding/json"
"fmt"
"time"
@ -223,11 +224,11 @@ type ReviewImage struct {
}
type Signal struct {
ID int64 `json:"id"`
TitleID *int64 `json:"title_id"`
RawData []byte `json:"raw_data"`
ProviderID int64 `json:"provider_id"`
Pending bool `json:"pending"`
ID int64 `json:"id"`
TitleID *int64 `json:"title_id"`
RawData json.RawMessage `json:"raw_data"`
ProviderID int64 `json:"provider_id"`
Pending bool `json:"pending"`
}
type Studio struct {
@ -238,13 +239,13 @@ type Studio struct {
}
type Tag struct {
ID int64 `json:"id"`
TagNames []byte `json:"tag_names"`
ID int64 `json:"id"`
TagNames json.RawMessage `json:"tag_names"`
}
type Title 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"`

View file

@ -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"`

View file

@ -14,6 +14,8 @@ sql:
emit_pointers_for_null_types: true
emit_empty_slices: true #slices returned by :many queries will be empty instead of nil
overrides:
- db_type: "jsonb"
go_type: "encoding/json.RawMessage"
- db_type: "uuid"
nullable: false
go_type: