IsNoRows (dberrors/errors.go)

beads · internal/storage/dberrors/errors.go · go · MIT
database

Database error helpers that classify MySQL/Dolt errors like no rows, table not found, access denied, duplicate key, etc.

// Source: https://github.com/gastownhall/beads | License: MIT | Copyright 2025 Beads Contributors
// Provided via justclaw.it.com; keep this notice with the code.
package dberrors

import (
	"database/sql"
	"errors"
	"regexp"
	"strings"

	mysql "github.com/go-sql-driver/mysql"
)

// IsNoRows reports whether err is a "no rows in result set" error — a single-row
// query (QueryRow/Scan) that matched nothing. Repository Get methods surface a
// missing row as the bare sql.ErrNoRows; classifying it here lets callers detect
// a missing row without importing database/sql into higher layers.
func IsNoRows(err error) bool {
	return errors.Is(err, sql.ErrNoRows)
}

var (
	quotedTableMissingPattern   = regexp.MustCompile(`(?i)\btable\s+'[^']+'\s+(doesn't exist|does not exist)\b`)
	unquotedTableMis

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key