stash/pkg/sqlite/values.go
departure18 776c7e6c35
Add penis length and circumcision stats to performers. (#3627)
* Add penis length stat to performers.
* Modified the UI to display and edit the stat.
* Added the ability to filter floats to allow filtering by penis length.
* Add circumcision stat to performer.
* Refactor enum filtering
* Change boolean filter to radio buttons
* Return null for empty enum values
---------
Co-authored-by: WithoutPants <53250216+WithoutPants@users.noreply.github.com>
2023-05-24 13:19:35 +10:00

70 lines
1,023 B
Go

package sqlite
import (
"github.com/stashapp/stash/pkg/file"
"gopkg.in/guregu/null.v4"
)
// 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) *file.FolderID {
if !i.Valid {
return nil
}
v := file.FolderID(i.Int64)
return &v
}
func nullIntFileIDPtr(i null.Int) *file.ID {
if !i.Valid {
return nil
}
v := file.ID(i.Int64)
return &v
}
func nullIntFromFileIDPtr(i *file.ID) null.Int {
if i == nil {
return null.NewInt(0, false)
}
return null.IntFrom(int64(*i))
}
func nullIntFromFolderIDPtr(i *file.FolderID) null.Int {
if i == nil {
return null.NewInt(0, false)
}
return null.IntFrom(int64(*i))
}