mirror of
https://github.com/stashapp/stash.git
synced 2025-12-06 16:34:02 +01:00
* 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
70 lines
1 KiB
Go
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))
|
|
}
|