2022-07-13 06:30:54 +00:00
|
|
|
package sqlite
|
|
|
|
|
|
|
|
import (
|
|
|
|
"gopkg.in/guregu/null.v4"
|
2023-09-01 00:39:29 +00:00
|
|
|
|
|
|
|
"github.com/stashapp/stash/pkg/models"
|
2022-07-13 06:30:54 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// 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
|
|
|
|
}
|
|
|
|
|
2023-05-24 03:19:35 +00:00
|
|
|
func nullFloatPtr(i null.Float) *float64 {
|
|
|
|
if !i.Valid {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
v := float64(i.Float64)
|
|
|
|
return &v
|
|
|
|
}
|
|
|
|
|
2023-09-01 00:39:29 +00:00
|
|
|
func nullIntFolderIDPtr(i null.Int) *models.FolderID {
|
2022-07-13 06:30:54 +00:00
|
|
|
if !i.Valid {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2023-09-01 00:39:29 +00:00
|
|
|
v := models.FolderID(i.Int64)
|
2022-07-13 06:30:54 +00:00
|
|
|
|
|
|
|
return &v
|
|
|
|
}
|
|
|
|
|
2023-09-01 00:39:29 +00:00
|
|
|
func nullIntFileIDPtr(i null.Int) *models.FileID {
|
2022-07-13 06:30:54 +00:00
|
|
|
if !i.Valid {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2023-09-01 00:39:29 +00:00
|
|
|
v := models.FileID(i.Int64)
|
2022-07-13 06:30:54 +00:00
|
|
|
|
|
|
|
return &v
|
|
|
|
}
|
|
|
|
|
2023-09-01 00:39:29 +00:00
|
|
|
func nullIntFromFileIDPtr(i *models.FileID) null.Int {
|
2022-07-13 06:30:54 +00:00
|
|
|
if i == nil {
|
|
|
|
return null.NewInt(0, false)
|
|
|
|
}
|
|
|
|
|
|
|
|
return null.IntFrom(int64(*i))
|
|
|
|
}
|
|
|
|
|
2023-09-01 00:39:29 +00:00
|
|
|
func nullIntFromFolderIDPtr(i *models.FolderID) null.Int {
|
2022-07-13 06:30:54 +00:00
|
|
|
if i == nil {
|
|
|
|
return null.NewInt(0, false)
|
|
|
|
}
|
|
|
|
|
|
|
|
return null.IntFrom(int64(*i))
|
|
|
|
}
|