mirror of
https://github.com/stashapp/stash.git
synced 2025-12-18 04:44:37 +03:00
Fix scene marker issues (#3955)
* Fix scene marker NOT NULL constraint error * similar changes to gallery chapters * Fix NULL conversion error if names are NULL in DB * Fix scene marker form resetting
This commit is contained in:
@@ -20,7 +20,7 @@ const (
|
||||
|
||||
type galleryChapterRow struct {
|
||||
ID int `db:"id" goqu:"skipinsert"`
|
||||
Title string `db:"title"`
|
||||
Title string `db:"title"` // TODO: make db schema (and gql schema) nullable
|
||||
ImageIndex int `db:"image_index"`
|
||||
GalleryID int `db:"gallery_id"`
|
||||
CreatedAt Timestamp `db:"created_at"`
|
||||
@@ -54,7 +54,12 @@ type galleryChapterRowRecord struct {
|
||||
}
|
||||
|
||||
func (r *galleryChapterRowRecord) fromPartial(o models.GalleryChapterPartial) {
|
||||
r.setString("title", o.Title)
|
||||
// TODO: replace with setNullString after schema is made nullable
|
||||
// r.setNullString("title", o.Title)
|
||||
// saves a null input as the empty string
|
||||
if o.Title.Set {
|
||||
r.set("title", o.Title.Value)
|
||||
}
|
||||
r.setInt("image_index", o.ImageIndex)
|
||||
r.setInt("gallery_id", o.GalleryID)
|
||||
r.setTimestamp("created_at", o.CreatedAt)
|
||||
|
||||
@@ -30,7 +30,7 @@ const (
|
||||
|
||||
type performerRow struct {
|
||||
ID int `db:"id" goqu:"skipinsert"`
|
||||
Name string `db:"name"`
|
||||
Name null.String `db:"name"` // TODO: make schema non-nullable
|
||||
Disambigation zero.String `db:"disambiguation"`
|
||||
Gender zero.String `db:"gender"`
|
||||
URL zero.String `db:"url"`
|
||||
@@ -65,7 +65,7 @@ type performerRow struct {
|
||||
|
||||
func (r *performerRow) fromPerformer(o models.Performer) {
|
||||
r.ID = o.ID
|
||||
r.Name = o.Name
|
||||
r.Name = null.StringFrom(o.Name)
|
||||
r.Disambigation = zero.StringFrom(o.Disambiguation)
|
||||
if o.Gender != nil && o.Gender.IsValid() {
|
||||
r.Gender = zero.StringFrom(o.Gender.String())
|
||||
@@ -101,7 +101,7 @@ func (r *performerRow) fromPerformer(o models.Performer) {
|
||||
func (r *performerRow) resolve() *models.Performer {
|
||||
ret := &models.Performer{
|
||||
ID: r.ID,
|
||||
Name: r.Name,
|
||||
Name: r.Name.String,
|
||||
Disambiguation: r.Disambigation.String,
|
||||
URL: r.URL.String,
|
||||
Twitter: r.Twitter.String,
|
||||
|
||||
@@ -25,7 +25,7 @@ GROUP BY scene_markers.id
|
||||
|
||||
type sceneMarkerRow struct {
|
||||
ID int `db:"id" goqu:"skipinsert"`
|
||||
Title string `db:"title"`
|
||||
Title string `db:"title"` // TODO: make db schema (and gql schema) nullable
|
||||
Seconds float64 `db:"seconds"`
|
||||
PrimaryTagID int `db:"primary_tag_id"`
|
||||
SceneID int `db:"scene_id"`
|
||||
@@ -62,7 +62,12 @@ type sceneMarkerRowRecord struct {
|
||||
}
|
||||
|
||||
func (r *sceneMarkerRowRecord) fromPartial(o models.SceneMarkerPartial) {
|
||||
r.setNullString("title", o.Title)
|
||||
// TODO: replace with setNullString after schema is made nullable
|
||||
// r.setNullString("title", o.Title)
|
||||
// saves a null input as the empty string
|
||||
if o.Title.Set {
|
||||
r.set("title", o.Title.Value)
|
||||
}
|
||||
r.setFloat64("seconds", o.Seconds)
|
||||
r.setInt("primary_tag_id", o.PrimaryTagID)
|
||||
r.setInt("scene_id", o.SceneID)
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
"github.com/doug-martin/goqu/v9"
|
||||
"github.com/doug-martin/goqu/v9/exp"
|
||||
"github.com/jmoiron/sqlx"
|
||||
"gopkg.in/guregu/null.v4"
|
||||
"gopkg.in/guregu/null.v4/zero"
|
||||
|
||||
"github.com/stashapp/stash/pkg/models"
|
||||
@@ -27,7 +28,7 @@ const (
|
||||
|
||||
type tagRow struct {
|
||||
ID int `db:"id" goqu:"skipinsert"`
|
||||
Name string `db:"name"`
|
||||
Name null.String `db:"name"` // TODO: make schema non-nullable
|
||||
Description zero.String `db:"description"`
|
||||
IgnoreAutoTag bool `db:"ignore_auto_tag"`
|
||||
CreatedAt Timestamp `db:"created_at"`
|
||||
@@ -39,7 +40,7 @@ type tagRow struct {
|
||||
|
||||
func (r *tagRow) fromTag(o models.Tag) {
|
||||
r.ID = o.ID
|
||||
r.Name = o.Name
|
||||
r.Name = null.StringFrom(o.Name)
|
||||
r.Description = zero.StringFrom(o.Description)
|
||||
r.IgnoreAutoTag = o.IgnoreAutoTag
|
||||
r.CreatedAt = Timestamp{Timestamp: o.CreatedAt}
|
||||
@@ -49,7 +50,7 @@ func (r *tagRow) fromTag(o models.Tag) {
|
||||
func (r *tagRow) resolve() *models.Tag {
|
||||
ret := &models.Tag{
|
||||
ID: r.ID,
|
||||
Name: r.Name,
|
||||
Name: r.Name.String,
|
||||
Description: r.Description.String,
|
||||
IgnoreAutoTag: r.IgnoreAutoTag,
|
||||
CreatedAt: r.CreatedAt.Timestamp,
|
||||
|
||||
Reference in New Issue
Block a user