dbutil

package
v0.13.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package dbutil provides shared helpers for database-layer operations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsUniqueViolation

func IsUniqueViolation(err error) bool

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 NullInt32

func NullInt32(p *int) *int64

NullInt32 converts a *int to a *int64. A nil pointer yields nil.

func NullInt32FromInt64Ptr

func NullInt32FromInt64Ptr(p *int64) *int64

NullInt32FromInt64Ptr returns p unchanged; SQLite-sqlc emits *int64 for nullable integer columns. Kept under the old name so existing call sites continue to compile against the migrated API.

func NullInt32Value

func NullInt32Value(p *int64) int

NullInt32Value returns the dereferenced value of p, or 0 if nil.

func NullString

func NullString(p *string) *string

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

func NullStringFromString(s string) *string

NullStringFromString converts a string to a nullable *string. An empty string yields nil (so it stores as SQL NULL).

func NullStringPtr

func NullStringPtr(p *string) *string

NullStringPtr is the identity for *string. Keeps the call-site name stable against the pre-SQLite signature, which converted sql.NullString → *string.

func NullStringValue

func NullStringValue(p *string) string

NullStringValue returns the dereferenced value of p, or "" if nil.

func NullTime

func NullTime(p *time.Time) *string

NullTime converts a *time.Time to its RFC3339 UTC string representation. A nil pointer yields nil so the column stores as SQL NULL.

TIMESTAMPTZ columns are stored as TEXT in SQLite (see migration squash); using RFC3339 keeps lexicographic ordering identical to chronological ordering, which several queries rely on.

func NullTimePtr

func NullTimePtr(s *string) *time.Time

NullTimePtr parses an RFC3339-encoded *string back to *time.Time. Nil or unparseable input yields nil.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL