Documentation
¶
Overview ¶
Package dbutil provides shared helpers for database-layer operations.
Index ¶
- func IsUniqueViolation(err error) bool
- func MergeSettings(existing, newSettings json.RawMessage) json.RawMessage
- func NullInt32Value(p *int64) int
- func NullString(p *string) *string
- func NullStringFromString(s string) *string
- func NullStringPtr(p *string) *string
- func NullStringValue(p *string) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsUniqueViolation ¶
IsUniqueViolation reports whether err is a SQLite unique constraint violation (extended result codes SQLITE_CONSTRAINT_UNIQUE / SQLITE_CONSTRAINT_PRIMARYKEY).
func MergeSettings ¶
func MergeSettings(existing, newSettings json.RawMessage) json.RawMessage
MergeSettings returns newSettings with any keys absent from newSettings filled in from existing. Keys present in newSettings always win. This is used to preserve secret fields (passwords, API keys) when the frontend omits them from an update request.
func NullInt32Value ¶
NullInt32Value returns the dereferenced value of p, or 0 if nil.
func NullString ¶
NullString returns p unchanged. It exists as a no-op for callers that built against the older sql.NullString-based API; keep it so adoption is grep-free. Empty strings are preserved (they are not coerced to nil) — callers that want "" treated as NULL should call NullStringFromString.
func NullStringFromString ¶
NullStringFromString converts a string to a nullable *string. An empty string yields nil (so it stores as SQL NULL).
func NullStringPtr ¶
NullStringPtr is the identity for *string. Keeps the call-site name stable against the pre-SQLite signature, which converted sql.NullString → *string.
func NullStringValue ¶
NullStringValue returns the dereferenced value of p, or "" if nil.
Types ¶
This section is empty.