stash/pkg/sqlite/values.go
DingDongSoLong4 c364346a59
Model refactor (#3915)
* Add mockery config file
* Move basic file/folder structs to models
* Fix hack due to import loop
* Move file interfaces to models
* Move folder interfaces to models
* Move scene interfaces to models
* Move scene marker interfaces to models
* Move image interfaces to models
* Move gallery interfaces to models
* Move gallery chapter interfaces to models
* Move studio interfaces to models
* Move movie interfaces to models
* Move performer interfaces to models
* Move tag interfaces to models
* Move autotag interfaces to models
* Regenerate mocks
2023-09-01 10:39:29 +10:00

70 lines
1 KiB
Go

package sqlite
import (
"gopkg.in/guregu/null.v4"
"github.com/stashapp/stash/pkg/models"
)
// null package does not provide methods to convert null.Int to int pointer
func intFromPtr(i *int) null.Int {
if i == nil {
return null.NewInt(0, false)
}
return null.IntFrom(int64(*i))
}
func nullIntPtr(i null.Int) *int {
if !i.Valid {
return nil
}
v := int(i.Int64)
return &v
}
func nullFloatPtr(i null.Float) *float64 {
if !i.Valid {
return nil
}
v := float64(i.Float64)
return &v
}
func nullIntFolderIDPtr(i null.Int) *models.FolderID {
if !i.Valid {
return nil
}
v := models.FolderID(i.Int64)
return &v
}
func nullIntFileIDPtr(i null.Int) *models.FileID {
if !i.Valid {
return nil
}
v := models.FileID(i.Int64)
return &v
}
func nullIntFromFileIDPtr(i *models.FileID) null.Int {
if i == nil {
return null.NewInt(0, false)
}
return null.IntFrom(int64(*i))
}
func nullIntFromFolderIDPtr(i *models.FolderID) null.Int {
if i == nil {
return null.NewInt(0, false)
}
return null.IntFrom(int64(*i))
}