autobrr/internal/database/utils.go
ze0s 604c7896bd
chore: add LICENSE GPLv2-or-later (#897)
* chore: add LICENSE

* chore: add LICENSE to README
2023-05-01 16:21:59 +02:00

44 lines
734 B
Go

// Copyright (c) 2021 - 2023, Ludvig Lundgren and the autobrr contributors.
// SPDX-License-Identifier: GPL-2.0-or-later
package database
import (
"database/sql"
"path"
)
func dataSourceName(configPath string, name string) string {
if configPath != "" {
return path.Join(configPath, name)
}
return name
}
func toNullString(s string) sql.NullString {
return sql.NullString{
String: s,
Valid: s != "",
}
}
func toNullInt32(s int32) sql.NullInt32 {
return sql.NullInt32{
Int32: s,
Valid: s != 0,
}
}
func toNullInt64(s int64) sql.NullInt64 {
return sql.NullInt64{
Int64: s,
Valid: s != 0,
}
}
func toNullFloat64(s float64) sql.NullFloat64 {
return sql.NullFloat64{
Float64: s,
Valid: s != 0,
}
}