mirror of
https://github.com/stashapp/stash.git
synced 2026-05-08 04:21:11 +02:00
* Bump go version in go.mod * Update compiler image. Changed github download url since existing one didn't have version 12 of the SDK. * Update macOS requirements in README for v0.32.0 * Update lint action * Bump golangci-lint version * Migrate golangci-lint config * Fix QF1012 errors (Use fmt.Fprintf(...) instead of WriteString(fmt.Sprintf(...))) * Fix QF1003 errors (could use tagged switch) * Fix ST1005 errors (error string capitalisation) * Fix ST1011 errors (seconds suffix) * Fix QF1006 errors (lift into loop condition) * Fix QF1002 errors (switch condition) * Fix gocritic error (deprecated paragraph) * Fix incorrect nolint directive * Ignore specific checks noctx should be addressed in a later PR --------- Co-authored-by: DogmaDragon <103123951+DogmaDragon@users.noreply.github.com> Co-authored-by: feederbox826 <me@feederbox.cc>
108 lines
2.4 KiB
Go
108 lines
2.4 KiB
Go
package sqlite
|
|
|
|
import (
|
|
"github.com/doug-martin/goqu/v9/exp"
|
|
"github.com/stashapp/stash/pkg/models"
|
|
"gopkg.in/guregu/null.v4"
|
|
"gopkg.in/guregu/null.v4/zero"
|
|
)
|
|
|
|
type updateRecord struct {
|
|
exp.Record
|
|
}
|
|
|
|
func (r *updateRecord) set(destField string, v interface{}) {
|
|
r.Record[destField] = v
|
|
}
|
|
|
|
func (r *updateRecord) setString(destField string, v models.OptionalString) {
|
|
if v.Set {
|
|
if v.Null {
|
|
panic("null value not allowed in optional string")
|
|
}
|
|
r.set(destField, v.Value)
|
|
}
|
|
}
|
|
|
|
func (r *updateRecord) setNullString(destField string, v models.OptionalString) {
|
|
if v.Set {
|
|
r.set(destField, zero.StringFromPtr(v.Ptr()))
|
|
}
|
|
}
|
|
|
|
func (r *updateRecord) setBool(destField string, v models.OptionalBool) {
|
|
if v.Set {
|
|
if v.Null {
|
|
panic("null value not allowed in optional bool")
|
|
}
|
|
r.set(destField, v.Value)
|
|
}
|
|
}
|
|
|
|
func (r *updateRecord) setInt(destField string, v models.OptionalInt) {
|
|
if v.Set {
|
|
if v.Null {
|
|
panic("null value not allowed in optional int")
|
|
}
|
|
r.set(destField, v.Value)
|
|
}
|
|
}
|
|
|
|
func (r *updateRecord) setNullInt(destField string, v models.OptionalInt) {
|
|
if v.Set {
|
|
r.set(destField, intFromPtr(v.Ptr()))
|
|
}
|
|
}
|
|
|
|
// func (r *updateRecord) setInt64(destField string, v models.OptionalInt64) {
|
|
// if v.Set {
|
|
// if v.Null {
|
|
// panic("null value not allowed in optional int64")
|
|
// }
|
|
// r.set(destField, v.Value)
|
|
// }
|
|
// }
|
|
|
|
// func (r *updateRecord) setNullInt64(destField string, v models.OptionalInt64) {
|
|
// if v.Set {
|
|
// r.set(destField, null.IntFromPtr(v.Ptr()))
|
|
// }
|
|
// }
|
|
|
|
func (r *updateRecord) setFloat64(destField string, v models.OptionalFloat64) {
|
|
if v.Set {
|
|
if v.Null {
|
|
panic("null value not allowed in optional float64")
|
|
}
|
|
r.set(destField, v.Value)
|
|
}
|
|
}
|
|
|
|
func (r *updateRecord) setNullFloat64(destField string, v models.OptionalFloat64) {
|
|
if v.Set {
|
|
r.set(destField, null.FloatFromPtr(v.Ptr()))
|
|
}
|
|
}
|
|
|
|
func (r *updateRecord) setTimestamp(destField string, v models.OptionalTime) {
|
|
if v.Set {
|
|
if v.Null {
|
|
panic("null value not allowed in optional time")
|
|
}
|
|
r.set(destField, Timestamp{Timestamp: v.Value})
|
|
}
|
|
}
|
|
|
|
//nolint:unused
|
|
func (r *updateRecord) setNullTimestamp(destField string, v models.OptionalTime) {
|
|
if v.Set {
|
|
r.set(destField, NullTimestampFromTimePtr(v.Ptr()))
|
|
}
|
|
}
|
|
|
|
func (r *updateRecord) setNullDate(destField string, precisionField string, v models.OptionalDate) {
|
|
if v.Set {
|
|
r.set(destField, NullDateFromDatePtr(v.Ptr()))
|
|
r.set(precisionField, datePrecisionFromDatePtr(v.Ptr()))
|
|
}
|
|
}
|