Documentation
¶
Overview ¶
Package sqlutil holds the helpers every persistence package needs.
It exists because the store is no longer one package. A sub-repository cannot import the store that owns it, so anything defined only in store is something a sub-repository has to reinvent — and that is not a theory: scheduleproposal grew its own copies of ParseTime and ExpectOne, and the ExpectOne copy drifted to returning a formatted string instead of the conflict sentinel, which silently broke errors.Is for that whole package.
Everything here is deliberately small and stateless. A clock belongs to the repository that owns it, not to a shared package.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BoundedError ¶
BoundedError caps a stored error message so one runaway string cannot dominate a row.
func ExpectOne ¶
ExpectOne turns a write that should have touched exactly one row into an error when it did not.
A miss is core.ErrConflict, not a formatted message, because the caller has to be able to tell "someone else got there first" from a real failure with errors.Is. That distinction is what the duplicated copy of this function lost.
func ParseTime ¶
ParseTime reads a stored timestamp, returning the zero time for anything unreadable.
Reads use core.TimestampParseFormat rather than the write format on purpose: Go requires exactly the layout's digit count when a fraction is written with zeros, so parsing with the write format rejects every value stored before timestamps became fixed-width — including one in a restored backup.
func ScanTime ¶
func ScanTime(value sql.NullString) time.Time
ScanTime reads a nullable stored timestamp.
Types ¶
type RowScanner ¶
RowScanner is whatever a query returned that can be scanned — a *sql.Row or a *sql.Rows — so one scan function serves both the single-row and the iterating call sites.
Shared for the same reason as everything else here: it was defined three times across store, memorystore and schedulestore.