sqlid

package
v0.64.0 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package sqlid validates SQL identifiers (table names) before they are interpolated into DDL/DML, guarding against SQL identifier injection. It composes on database/identifier: each dot-separated part is judged by that package's Oracle grammar, the union alphabet (letters, digits, underscore, $, #) every vendor the framework supports accepts, so the grammar has one home and cannot drift from the renderers'.

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 LeaderTableName added in v0.61.0

func LeaderTableName(name string) string

LeaderTableName returns the companion leader-table name for a table, preserving any schema prefix ("myschema.outbox" -> "myschema.outbox_leader"). The input has already passed ValidateTableName.

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 or exceeds identifier.MaxOracleBytes. 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