relation

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: Apache-2.0 Imports: 5 Imported by: 1 module, 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 relation defines canonical MySQL physical-relation identities.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidIdentifier = errors.New("invalid MySQL identifier")

ErrInvalidIdentifier reports an identifier that cannot be safely used as a MySQL database or table name.

Functions

func QuoteIdentifier

func QuoteIdentifier(name string) (string, error)

QuoteIdentifier validates and quotes one MySQL identifier.

func QuoteQualified

func QuoteQualified(database, table string) (string, error)

QuoteQualified validates and quotes a database-qualified table name.

func ValidateIdentifier

func ValidateIdentifier(name string) error

ValidateIdentifier validates one non-empty MySQL database or table identifier.

Types

type Canonicalizer

type Canonicalizer struct {
	// contains filtered or unexported fields
}

Canonicalizer applies one frozen lower_case_table_names mode.

func MustCanonicalizer

func MustCanonicalizer(mode int) Canonicalizer

MustCanonicalizer constructs a canonicalizer and panics for an invalid mode.

func NewCanonicalizer

func NewCanonicalizer(mode int) (Canonicalizer, error)

NewCanonicalizer constructs a canonicalizer for lower_case_table_names 0, 1, or 2.

func (Canonicalizer) Identifier

func (c Canonicalizer) Identifier(name string) string

Identifier returns the canonical lookup form of an identifier.

func (Canonicalizer) Identity

func (c Canonicalizer) Identity(database, table string) Identity

Identity returns canonical lookup identity while retaining display spelling.

func (Canonicalizer) Key

func (c Canonicalizer) Key(database, table string) Key

Key returns a canonical physical-relation lookup key.

func (Canonicalizer) Mode

func (c Canonicalizer) Mode() CaseMode

Mode returns the frozen lower_case_table_names mode.

type CaseMode

type CaseMode uint8

CaseMode mirrors MySQL lower_case_table_names.

const (
	// CaseSensitive preserves identifier case in lookup keys.
	CaseSensitive CaseMode = iota
	// CaseLower stores and compares identifier lookup keys in lowercase.
	CaseLower
	// CaseInsensitive compares lowercase lookup keys while preserving display names.
	CaseInsensitive
)

type Identity

type Identity struct {
	Key             Key
	DisplayDatabase string
	DisplayTable    string
}

Identity carries canonical lookup identity and display-preserving names.

type Key

type Key struct {
	Database string
	Table    string
}

Key is the canonical lookup identity of one physical MySQL relation.

func (Key) Empty

func (k Key) Empty() bool

Empty reports whether the key does not identify a physical relation.

func (Key) Encode

func (k Key) Encode() string

Encode returns an unambiguous, stable representation suitable for cache keys. Length prefixes avoid collisions involving dots or other punctuation.

Jump to

Keyboard shortcuts

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