sqlid

package
v0.40.1 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package sqlid validates SQL identifiers (table names) before they are interpolated into DDL/DML, guarding against SQL identifier injection. The rules mirror the historical outbox validator and database/internal/columns/parser.go for consistency across the framework.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IndexBaseName

func IndexBaseName(name string) string

IndexBaseName returns the unqualified last dot-separated segment of name, used to derive index (and similar) identifier names. An index name cannot be schema-qualified, so a schema-qualified table like "myschema.events" must base its index names on "events" while the index still targets the qualified table.

func ValidateTableName

func ValidateTableName(name string) error

ValidateTableName checks that name is a safe SQL identifier. Supports optional schema-qualified names (e.g., "myschema.table"). Returns a descriptive error when name is empty, contains dangerous SQL fragments, has more than two dot-separated parts, or any part is not a valid identifier. The error message has no package prefix; callers wrap it with their own prefix (e.g. fmt.Errorf("outbox: %w", err)).

Types

This section is empty.

Jump to

Keyboard shortcuts

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