mirror of
https://github.com/stashapp/stash.git
synced 2025-12-06 08:26:00 +01:00
Add date precision columns for date columns
This commit is contained in:
parent
b4b1f4d7a1
commit
71587b9dc9
9 changed files with 102 additions and 67 deletions
|
|
@ -34,7 +34,7 @@ const (
|
||||||
cacheSizeEnv = "STASH_SQLITE_CACHE_SIZE"
|
cacheSizeEnv = "STASH_SQLITE_CACHE_SIZE"
|
||||||
)
|
)
|
||||||
|
|
||||||
var appSchemaVersion uint = 74
|
var appSchemaVersion uint = 75
|
||||||
|
|
||||||
//go:embed migrations/*.sql
|
//go:embed migrations/*.sql
|
||||||
var migrationsBox embed.FS
|
var migrationsBox embed.FS
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/stashapp/stash/pkg/models"
|
"github.com/stashapp/stash/pkg/models"
|
||||||
|
"gopkg.in/guregu/null.v4"
|
||||||
)
|
)
|
||||||
|
|
||||||
const sqliteDateLayout = "2006-01-02"
|
const sqliteDateLayout = "2006-01-02"
|
||||||
|
|
@ -54,12 +55,12 @@ func (d NullDate) Value() (driver.Value, error) {
|
||||||
return d.Date.Format(sqliteDateLayout), nil
|
return d.Date.Format(sqliteDateLayout), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *NullDate) DatePtr() *models.Date {
|
func (d *NullDate) DatePtr(precision null.Int) *models.Date {
|
||||||
if d == nil || !d.Valid {
|
if d == nil || !d.Valid {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return &models.Date{Time: d.Date}
|
return &models.Date{Time: d.Date, Precision: models.DatePrecision(precision.Int64)}
|
||||||
}
|
}
|
||||||
|
|
||||||
func NullDateFromDatePtr(d *models.Date) NullDate {
|
func NullDateFromDatePtr(d *models.Date) NullDate {
|
||||||
|
|
@ -68,3 +69,11 @@ func NullDateFromDatePtr(d *models.Date) NullDate {
|
||||||
}
|
}
|
||||||
return NullDate{Date: d.Time, Valid: true}
|
return NullDate{Date: d.Time, Valid: true}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func datePrecisionFromDatePtr(d *models.Date) null.Int {
|
||||||
|
if d == nil {
|
||||||
|
// default to day precision
|
||||||
|
return null.Int{}
|
||||||
|
}
|
||||||
|
return null.IntFrom(int64(d.Precision))
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,12 +30,13 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
type galleryRow struct {
|
type galleryRow struct {
|
||||||
ID int `db:"id" goqu:"skipinsert"`
|
ID int `db:"id" goqu:"skipinsert"`
|
||||||
Title zero.String `db:"title"`
|
Title zero.String `db:"title"`
|
||||||
Code zero.String `db:"code"`
|
Code zero.String `db:"code"`
|
||||||
Date NullDate `db:"date"`
|
Date NullDate `db:"date"`
|
||||||
Details zero.String `db:"details"`
|
DatePrecision null.Int `db:"date_precision"`
|
||||||
Photographer zero.String `db:"photographer"`
|
Details zero.String `db:"details"`
|
||||||
|
Photographer zero.String `db:"photographer"`
|
||||||
// expressed as 1-100
|
// expressed as 1-100
|
||||||
Rating null.Int `db:"rating"`
|
Rating null.Int `db:"rating"`
|
||||||
Organized bool `db:"organized"`
|
Organized bool `db:"organized"`
|
||||||
|
|
@ -50,6 +51,7 @@ func (r *galleryRow) fromGallery(o models.Gallery) {
|
||||||
r.Title = zero.StringFrom(o.Title)
|
r.Title = zero.StringFrom(o.Title)
|
||||||
r.Code = zero.StringFrom(o.Code)
|
r.Code = zero.StringFrom(o.Code)
|
||||||
r.Date = NullDateFromDatePtr(o.Date)
|
r.Date = NullDateFromDatePtr(o.Date)
|
||||||
|
r.DatePrecision = datePrecisionFromDatePtr(o.Date)
|
||||||
r.Details = zero.StringFrom(o.Details)
|
r.Details = zero.StringFrom(o.Details)
|
||||||
r.Photographer = zero.StringFrom(o.Photographer)
|
r.Photographer = zero.StringFrom(o.Photographer)
|
||||||
r.Rating = intFromPtr(o.Rating)
|
r.Rating = intFromPtr(o.Rating)
|
||||||
|
|
@ -74,7 +76,7 @@ func (r *galleryQueryRow) resolve() *models.Gallery {
|
||||||
ID: r.ID,
|
ID: r.ID,
|
||||||
Title: r.Title.String,
|
Title: r.Title.String,
|
||||||
Code: r.Code.String,
|
Code: r.Code.String,
|
||||||
Date: r.Date.DatePtr(),
|
Date: r.Date.DatePtr(r.DatePrecision),
|
||||||
Details: r.Details.String,
|
Details: r.Details.String,
|
||||||
Photographer: r.Photographer.String,
|
Photographer: r.Photographer.String,
|
||||||
Rating: nullIntPtr(r.Rating),
|
Rating: nullIntPtr(r.Rating),
|
||||||
|
|
@ -102,7 +104,7 @@ type galleryRowRecord struct {
|
||||||
func (r *galleryRowRecord) fromPartial(o models.GalleryPartial) {
|
func (r *galleryRowRecord) fromPartial(o models.GalleryPartial) {
|
||||||
r.setNullString("title", o.Title)
|
r.setNullString("title", o.Title)
|
||||||
r.setNullString("code", o.Code)
|
r.setNullString("code", o.Code)
|
||||||
r.setNullDate("date", o.Date)
|
r.setNullDate("date", "date_precision", o.Date)
|
||||||
r.setNullString("details", o.Details)
|
r.setNullString("details", o.Details)
|
||||||
r.setNullString("photographer", o.Photographer)
|
r.setNullString("photographer", o.Photographer)
|
||||||
r.setNullInt("rating", o.Rating)
|
r.setNullInt("rating", o.Rating)
|
||||||
|
|
|
||||||
|
|
@ -32,11 +32,12 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
type groupRow struct {
|
type groupRow struct {
|
||||||
ID int `db:"id" goqu:"skipinsert"`
|
ID int `db:"id" goqu:"skipinsert"`
|
||||||
Name zero.String `db:"name"`
|
Name zero.String `db:"name"`
|
||||||
Aliases zero.String `db:"aliases"`
|
Aliases zero.String `db:"aliases"`
|
||||||
Duration null.Int `db:"duration"`
|
Duration null.Int `db:"duration"`
|
||||||
Date NullDate `db:"date"`
|
Date NullDate `db:"date"`
|
||||||
|
DatePrecision null.Int `db:"date_precision"`
|
||||||
// expressed as 1-100
|
// expressed as 1-100
|
||||||
Rating null.Int `db:"rating"`
|
Rating null.Int `db:"rating"`
|
||||||
StudioID null.Int `db:"studio_id,omitempty"`
|
StudioID null.Int `db:"studio_id,omitempty"`
|
||||||
|
|
@ -56,6 +57,7 @@ func (r *groupRow) fromGroup(o models.Group) {
|
||||||
r.Aliases = zero.StringFrom(o.Aliases)
|
r.Aliases = zero.StringFrom(o.Aliases)
|
||||||
r.Duration = intFromPtr(o.Duration)
|
r.Duration = intFromPtr(o.Duration)
|
||||||
r.Date = NullDateFromDatePtr(o.Date)
|
r.Date = NullDateFromDatePtr(o.Date)
|
||||||
|
r.DatePrecision = datePrecisionFromDatePtr(o.Date)
|
||||||
r.Rating = intFromPtr(o.Rating)
|
r.Rating = intFromPtr(o.Rating)
|
||||||
r.StudioID = intFromPtr(o.StudioID)
|
r.StudioID = intFromPtr(o.StudioID)
|
||||||
r.Director = zero.StringFrom(o.Director)
|
r.Director = zero.StringFrom(o.Director)
|
||||||
|
|
@ -70,7 +72,7 @@ func (r *groupRow) resolve() *models.Group {
|
||||||
Name: r.Name.String,
|
Name: r.Name.String,
|
||||||
Aliases: r.Aliases.String,
|
Aliases: r.Aliases.String,
|
||||||
Duration: nullIntPtr(r.Duration),
|
Duration: nullIntPtr(r.Duration),
|
||||||
Date: r.Date.DatePtr(),
|
Date: r.Date.DatePtr(r.DatePrecision),
|
||||||
Rating: nullIntPtr(r.Rating),
|
Rating: nullIntPtr(r.Rating),
|
||||||
StudioID: nullIntPtr(r.StudioID),
|
StudioID: nullIntPtr(r.StudioID),
|
||||||
Director: r.Director.String,
|
Director: r.Director.String,
|
||||||
|
|
@ -90,7 +92,7 @@ func (r *groupRowRecord) fromPartial(o models.GroupPartial) {
|
||||||
r.setNullString("name", o.Name)
|
r.setNullString("name", o.Name)
|
||||||
r.setNullString("aliases", o.Aliases)
|
r.setNullString("aliases", o.Aliases)
|
||||||
r.setNullInt("duration", o.Duration)
|
r.setNullInt("duration", o.Duration)
|
||||||
r.setNullDate("date", o.Date)
|
r.setNullDate("date", "date_precision", o.Date)
|
||||||
r.setNullInt("rating", o.Rating)
|
r.setNullInt("rating", o.Rating)
|
||||||
r.setNullInt("studio_id", o.StudioID)
|
r.setNullInt("studio_id", o.StudioID)
|
||||||
r.setNullString("director", o.Director)
|
r.setNullString("director", o.Director)
|
||||||
|
|
|
||||||
|
|
@ -34,15 +34,16 @@ type imageRow struct {
|
||||||
Title zero.String `db:"title"`
|
Title zero.String `db:"title"`
|
||||||
Code zero.String `db:"code"`
|
Code zero.String `db:"code"`
|
||||||
// expressed as 1-100
|
// expressed as 1-100
|
||||||
Rating null.Int `db:"rating"`
|
Rating null.Int `db:"rating"`
|
||||||
Date NullDate `db:"date"`
|
Date NullDate `db:"date"`
|
||||||
Details zero.String `db:"details"`
|
DatePrecision null.Int `db:"date_precision"`
|
||||||
Photographer zero.String `db:"photographer"`
|
Details zero.String `db:"details"`
|
||||||
Organized bool `db:"organized"`
|
Photographer zero.String `db:"photographer"`
|
||||||
OCounter int `db:"o_counter"`
|
Organized bool `db:"organized"`
|
||||||
StudioID null.Int `db:"studio_id,omitempty"`
|
OCounter int `db:"o_counter"`
|
||||||
CreatedAt Timestamp `db:"created_at"`
|
StudioID null.Int `db:"studio_id,omitempty"`
|
||||||
UpdatedAt Timestamp `db:"updated_at"`
|
CreatedAt Timestamp `db:"created_at"`
|
||||||
|
UpdatedAt Timestamp `db:"updated_at"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *imageRow) fromImage(i models.Image) {
|
func (r *imageRow) fromImage(i models.Image) {
|
||||||
|
|
@ -51,6 +52,7 @@ func (r *imageRow) fromImage(i models.Image) {
|
||||||
r.Code = zero.StringFrom(i.Code)
|
r.Code = zero.StringFrom(i.Code)
|
||||||
r.Rating = intFromPtr(i.Rating)
|
r.Rating = intFromPtr(i.Rating)
|
||||||
r.Date = NullDateFromDatePtr(i.Date)
|
r.Date = NullDateFromDatePtr(i.Date)
|
||||||
|
r.DatePrecision = datePrecisionFromDatePtr(i.Date)
|
||||||
r.Details = zero.StringFrom(i.Details)
|
r.Details = zero.StringFrom(i.Details)
|
||||||
r.Photographer = zero.StringFrom(i.Photographer)
|
r.Photographer = zero.StringFrom(i.Photographer)
|
||||||
r.Organized = i.Organized
|
r.Organized = i.Organized
|
||||||
|
|
@ -74,7 +76,7 @@ func (r *imageQueryRow) resolve() *models.Image {
|
||||||
Title: r.Title.String,
|
Title: r.Title.String,
|
||||||
Code: r.Code.String,
|
Code: r.Code.String,
|
||||||
Rating: nullIntPtr(r.Rating),
|
Rating: nullIntPtr(r.Rating),
|
||||||
Date: r.Date.DatePtr(),
|
Date: r.Date.DatePtr(r.DatePrecision),
|
||||||
Details: r.Details.String,
|
Details: r.Details.String,
|
||||||
Photographer: r.Photographer.String,
|
Photographer: r.Photographer.String,
|
||||||
Organized: r.Organized,
|
Organized: r.Organized,
|
||||||
|
|
@ -103,7 +105,7 @@ func (r *imageRowRecord) fromPartial(i models.ImagePartial) {
|
||||||
r.setNullString("title", i.Title)
|
r.setNullString("title", i.Title)
|
||||||
r.setNullString("code", i.Code)
|
r.setNullString("code", i.Code)
|
||||||
r.setNullInt("rating", i.Rating)
|
r.setNullInt("rating", i.Rating)
|
||||||
r.setNullDate("date", i.Date)
|
r.setNullDate("date", "date_precision", i.Date)
|
||||||
r.setNullString("details", i.Details)
|
r.setNullString("details", i.Details)
|
||||||
r.setNullString("photographer", i.Photographer)
|
r.setNullString("photographer", i.Photographer)
|
||||||
r.setBool("organized", i.Organized)
|
r.setBool("organized", i.Organized)
|
||||||
|
|
|
||||||
13
pkg/sqlite/migrations/75_date_precision.up.sql
Normal file
13
pkg/sqlite/migrations/75_date_precision.up.sql
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
ALTER TABLE "scenes" ADD COLUMN "date_precision" TINYINT;
|
||||||
|
ALTER TABLE "images" ADD COLUMN "date_precision" TINYINT;
|
||||||
|
ALTER TABLE "galleries" ADD COLUMN "date_precision" TINYINT;
|
||||||
|
ALTER TABLE "groups" ADD COLUMN "date_precision" TINYINT;
|
||||||
|
ALTER TABLE "performers" ADD COLUMN "birthdate_precision" TINYINT;
|
||||||
|
ALTER TABLE "performers" ADD COLUMN "death_date_precision" TINYINT;
|
||||||
|
|
||||||
|
UPDATE "scenes" SET "date_precision" = 0 WHERE "date" IS NOT NULL;
|
||||||
|
UPDATE "images" SET "date_precision" = 0 WHERE "date" IS NOT NULL;
|
||||||
|
UPDATE "galleries" SET "date_precision" = 0 WHERE "date" IS NOT NULL;
|
||||||
|
UPDATE "groups" SET "date_precision" = 0 WHERE "date" IS NOT NULL;
|
||||||
|
UPDATE "performers" SET "birthdate_precision" = 0 WHERE "birthdate" IS NOT NULL;
|
||||||
|
UPDATE "performers" SET "death_date_precision" = 0 WHERE "death_date" IS NOT NULL;
|
||||||
|
|
@ -30,32 +30,34 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
type performerRow struct {
|
type performerRow struct {
|
||||||
ID int `db:"id" goqu:"skipinsert"`
|
ID int `db:"id" goqu:"skipinsert"`
|
||||||
Name null.String `db:"name"` // TODO: make schema non-nullable
|
Name null.String `db:"name"` // TODO: make schema non-nullable
|
||||||
Disambigation zero.String `db:"disambiguation"`
|
Disambigation zero.String `db:"disambiguation"`
|
||||||
Gender zero.String `db:"gender"`
|
Gender zero.String `db:"gender"`
|
||||||
Birthdate NullDate `db:"birthdate"`
|
Birthdate NullDate `db:"birthdate"`
|
||||||
Ethnicity zero.String `db:"ethnicity"`
|
BirthdatePrecision null.Int `db:"birthdate_precision"`
|
||||||
Country zero.String `db:"country"`
|
Ethnicity zero.String `db:"ethnicity"`
|
||||||
EyeColor zero.String `db:"eye_color"`
|
Country zero.String `db:"country"`
|
||||||
Height null.Int `db:"height"`
|
EyeColor zero.String `db:"eye_color"`
|
||||||
Measurements zero.String `db:"measurements"`
|
Height null.Int `db:"height"`
|
||||||
FakeTits zero.String `db:"fake_tits"`
|
Measurements zero.String `db:"measurements"`
|
||||||
PenisLength null.Float `db:"penis_length"`
|
FakeTits zero.String `db:"fake_tits"`
|
||||||
Circumcised zero.String `db:"circumcised"`
|
PenisLength null.Float `db:"penis_length"`
|
||||||
CareerLength zero.String `db:"career_length"`
|
Circumcised zero.String `db:"circumcised"`
|
||||||
Tattoos zero.String `db:"tattoos"`
|
CareerLength zero.String `db:"career_length"`
|
||||||
Piercings zero.String `db:"piercings"`
|
Tattoos zero.String `db:"tattoos"`
|
||||||
Favorite bool `db:"favorite"`
|
Piercings zero.String `db:"piercings"`
|
||||||
CreatedAt Timestamp `db:"created_at"`
|
Favorite bool `db:"favorite"`
|
||||||
UpdatedAt Timestamp `db:"updated_at"`
|
CreatedAt Timestamp `db:"created_at"`
|
||||||
|
UpdatedAt Timestamp `db:"updated_at"`
|
||||||
// expressed as 1-100
|
// expressed as 1-100
|
||||||
Rating null.Int `db:"rating"`
|
Rating null.Int `db:"rating"`
|
||||||
Details zero.String `db:"details"`
|
Details zero.String `db:"details"`
|
||||||
DeathDate NullDate `db:"death_date"`
|
DeathDate NullDate `db:"death_date"`
|
||||||
HairColor zero.String `db:"hair_color"`
|
DeathDatePrecision null.Int `db:"death_date_precision"`
|
||||||
Weight null.Int `db:"weight"`
|
HairColor zero.String `db:"hair_color"`
|
||||||
IgnoreAutoTag bool `db:"ignore_auto_tag"`
|
Weight null.Int `db:"weight"`
|
||||||
|
IgnoreAutoTag bool `db:"ignore_auto_tag"`
|
||||||
|
|
||||||
// not used in resolution or updates
|
// not used in resolution or updates
|
||||||
ImageBlob zero.String `db:"image_blob"`
|
ImageBlob zero.String `db:"image_blob"`
|
||||||
|
|
@ -69,6 +71,7 @@ func (r *performerRow) fromPerformer(o models.Performer) {
|
||||||
r.Gender = zero.StringFrom(o.Gender.String())
|
r.Gender = zero.StringFrom(o.Gender.String())
|
||||||
}
|
}
|
||||||
r.Birthdate = NullDateFromDatePtr(o.Birthdate)
|
r.Birthdate = NullDateFromDatePtr(o.Birthdate)
|
||||||
|
r.BirthdatePrecision = datePrecisionFromDatePtr(o.Birthdate)
|
||||||
r.Ethnicity = zero.StringFrom(o.Ethnicity)
|
r.Ethnicity = zero.StringFrom(o.Ethnicity)
|
||||||
r.Country = zero.StringFrom(o.Country)
|
r.Country = zero.StringFrom(o.Country)
|
||||||
r.EyeColor = zero.StringFrom(o.EyeColor)
|
r.EyeColor = zero.StringFrom(o.EyeColor)
|
||||||
|
|
@ -88,6 +91,7 @@ func (r *performerRow) fromPerformer(o models.Performer) {
|
||||||
r.Rating = intFromPtr(o.Rating)
|
r.Rating = intFromPtr(o.Rating)
|
||||||
r.Details = zero.StringFrom(o.Details)
|
r.Details = zero.StringFrom(o.Details)
|
||||||
r.DeathDate = NullDateFromDatePtr(o.DeathDate)
|
r.DeathDate = NullDateFromDatePtr(o.DeathDate)
|
||||||
|
r.DeathDatePrecision = datePrecisionFromDatePtr(o.DeathDate)
|
||||||
r.HairColor = zero.StringFrom(o.HairColor)
|
r.HairColor = zero.StringFrom(o.HairColor)
|
||||||
r.Weight = intFromPtr(o.Weight)
|
r.Weight = intFromPtr(o.Weight)
|
||||||
r.IgnoreAutoTag = o.IgnoreAutoTag
|
r.IgnoreAutoTag = o.IgnoreAutoTag
|
||||||
|
|
@ -98,7 +102,7 @@ func (r *performerRow) resolve() *models.Performer {
|
||||||
ID: r.ID,
|
ID: r.ID,
|
||||||
Name: r.Name.String,
|
Name: r.Name.String,
|
||||||
Disambiguation: r.Disambigation.String,
|
Disambiguation: r.Disambigation.String,
|
||||||
Birthdate: r.Birthdate.DatePtr(),
|
Birthdate: r.Birthdate.DatePtr(r.BirthdatePrecision),
|
||||||
Ethnicity: r.Ethnicity.String,
|
Ethnicity: r.Ethnicity.String,
|
||||||
Country: r.Country.String,
|
Country: r.Country.String,
|
||||||
EyeColor: r.EyeColor.String,
|
EyeColor: r.EyeColor.String,
|
||||||
|
|
@ -115,7 +119,7 @@ func (r *performerRow) resolve() *models.Performer {
|
||||||
// expressed as 1-100
|
// expressed as 1-100
|
||||||
Rating: nullIntPtr(r.Rating),
|
Rating: nullIntPtr(r.Rating),
|
||||||
Details: r.Details.String,
|
Details: r.Details.String,
|
||||||
DeathDate: r.DeathDate.DatePtr(),
|
DeathDate: r.DeathDate.DatePtr(r.DeathDatePrecision),
|
||||||
HairColor: r.HairColor.String,
|
HairColor: r.HairColor.String,
|
||||||
Weight: nullIntPtr(r.Weight),
|
Weight: nullIntPtr(r.Weight),
|
||||||
IgnoreAutoTag: r.IgnoreAutoTag,
|
IgnoreAutoTag: r.IgnoreAutoTag,
|
||||||
|
|
@ -142,7 +146,7 @@ func (r *performerRowRecord) fromPartial(o models.PerformerPartial) {
|
||||||
r.setString("name", o.Name)
|
r.setString("name", o.Name)
|
||||||
r.setNullString("disambiguation", o.Disambiguation)
|
r.setNullString("disambiguation", o.Disambiguation)
|
||||||
r.setNullString("gender", o.Gender)
|
r.setNullString("gender", o.Gender)
|
||||||
r.setNullDate("birthdate", o.Birthdate)
|
r.setNullDate("birthdate", "birthdate_precision", o.Birthdate)
|
||||||
r.setNullString("ethnicity", o.Ethnicity)
|
r.setNullString("ethnicity", o.Ethnicity)
|
||||||
r.setNullString("country", o.Country)
|
r.setNullString("country", o.Country)
|
||||||
r.setNullString("eye_color", o.EyeColor)
|
r.setNullString("eye_color", o.EyeColor)
|
||||||
|
|
@ -159,7 +163,7 @@ func (r *performerRowRecord) fromPartial(o models.PerformerPartial) {
|
||||||
r.setTimestamp("updated_at", o.UpdatedAt)
|
r.setTimestamp("updated_at", o.UpdatedAt)
|
||||||
r.setNullInt("rating", o.Rating)
|
r.setNullInt("rating", o.Rating)
|
||||||
r.setNullString("details", o.Details)
|
r.setNullString("details", o.Details)
|
||||||
r.setNullDate("death_date", o.DeathDate)
|
r.setNullDate("death_date", "death_date_precision", o.DeathDate)
|
||||||
r.setNullString("hair_color", o.HairColor)
|
r.setNullString("hair_color", o.HairColor)
|
||||||
r.setNullInt("weight", o.Weight)
|
r.setNullInt("weight", o.Weight)
|
||||||
r.setBool("ignore_auto_tag", o.IgnoreAutoTag)
|
r.setBool("ignore_auto_tag", o.IgnoreAutoTag)
|
||||||
|
|
|
||||||
|
|
@ -100,8 +100,9 @@ func (r *updateRecord) setNullTimestamp(destField string, v models.OptionalTime)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *updateRecord) setNullDate(destField string, v models.OptionalDate) {
|
func (r *updateRecord) setNullDate(destField string, precisionField string, v models.OptionalDate) {
|
||||||
if v.Set {
|
if v.Set {
|
||||||
r.set(destField, NullDateFromDatePtr(v.Ptr()))
|
r.set(destField, NullDateFromDatePtr(v.Ptr()))
|
||||||
|
r.set(precisionField, datePrecisionFromDatePtr(v.Ptr()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -76,12 +76,13 @@ ORDER BY files.size DESC;
|
||||||
`
|
`
|
||||||
|
|
||||||
type sceneRow struct {
|
type sceneRow struct {
|
||||||
ID int `db:"id" goqu:"skipinsert"`
|
ID int `db:"id" goqu:"skipinsert"`
|
||||||
Title zero.String `db:"title"`
|
Title zero.String `db:"title"`
|
||||||
Code zero.String `db:"code"`
|
Code zero.String `db:"code"`
|
||||||
Details zero.String `db:"details"`
|
Details zero.String `db:"details"`
|
||||||
Director zero.String `db:"director"`
|
Director zero.String `db:"director"`
|
||||||
Date NullDate `db:"date"`
|
Date NullDate `db:"date"`
|
||||||
|
DatePrecision null.Int `db:"date_precision"`
|
||||||
// expressed as 1-100
|
// expressed as 1-100
|
||||||
Rating null.Int `db:"rating"`
|
Rating null.Int `db:"rating"`
|
||||||
Organized bool `db:"organized"`
|
Organized bool `db:"organized"`
|
||||||
|
|
@ -102,6 +103,7 @@ func (r *sceneRow) fromScene(o models.Scene) {
|
||||||
r.Details = zero.StringFrom(o.Details)
|
r.Details = zero.StringFrom(o.Details)
|
||||||
r.Director = zero.StringFrom(o.Director)
|
r.Director = zero.StringFrom(o.Director)
|
||||||
r.Date = NullDateFromDatePtr(o.Date)
|
r.Date = NullDateFromDatePtr(o.Date)
|
||||||
|
r.DatePrecision = datePrecisionFromDatePtr(o.Date)
|
||||||
r.Rating = intFromPtr(o.Rating)
|
r.Rating = intFromPtr(o.Rating)
|
||||||
r.Organized = o.Organized
|
r.Organized = o.Organized
|
||||||
r.StudioID = intFromPtr(o.StudioID)
|
r.StudioID = intFromPtr(o.StudioID)
|
||||||
|
|
@ -127,7 +129,7 @@ func (r *sceneQueryRow) resolve() *models.Scene {
|
||||||
Code: r.Code.String,
|
Code: r.Code.String,
|
||||||
Details: r.Details.String,
|
Details: r.Details.String,
|
||||||
Director: r.Director.String,
|
Director: r.Director.String,
|
||||||
Date: r.Date.DatePtr(),
|
Date: r.Date.DatePtr(r.DatePrecision),
|
||||||
Rating: nullIntPtr(r.Rating),
|
Rating: nullIntPtr(r.Rating),
|
||||||
Organized: r.Organized,
|
Organized: r.Organized,
|
||||||
StudioID: nullIntPtr(r.StudioID),
|
StudioID: nullIntPtr(r.StudioID),
|
||||||
|
|
@ -159,7 +161,7 @@ func (r *sceneRowRecord) fromPartial(o models.ScenePartial) {
|
||||||
r.setNullString("code", o.Code)
|
r.setNullString("code", o.Code)
|
||||||
r.setNullString("details", o.Details)
|
r.setNullString("details", o.Details)
|
||||||
r.setNullString("director", o.Director)
|
r.setNullString("director", o.Director)
|
||||||
r.setNullDate("date", o.Date)
|
r.setNullDate("date", "date_precision", o.Date)
|
||||||
r.setNullInt("rating", o.Rating)
|
r.setNullInt("rating", o.Rating)
|
||||||
r.setBool("organized", o.Organized)
|
r.setBool("organized", o.Organized)
|
||||||
r.setNullInt("studio_id", o.StudioID)
|
r.setNullInt("studio_id", o.StudioID)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue