mirror of
https://github.com/idanoo/autobrr
synced 2025-07-22 08:19:12 +00:00
44 lines
734 B
Go
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,
|
|
}
|
|
}
|