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:
DingDongSoLong4
2023-07-28 03:22:43 +02:00
committed by GitHub
parent 7b77b8986f
commit 95a78de3aa
9 changed files with 84 additions and 75 deletions

View File

@@ -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)