dialect

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2026 License: MIT Imports: 0 Imported by: 0

Documentation

Overview

Package dialect abstracts SQL dialect differences: identifier quoting, parameter placeholders, EXPLAIN wrapping, and capability negotiation.

Concrete dialect implementations live in x/providers alongside each database adapter. The heavier EXPLAIN-result parsing (cost.Explainer) and schema introspection (introspect.Introspector) also stay in x/providers because they require live database access. Capabilities drive both codegen rendering and which Gate layers are assembled per database.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Capabilities

type Capabilities struct {
	// Rendering.
	Returning    bool // INSERT ... RETURNING (PG/OB-Oracle have; MySQL lacks -> second SELECT for last id)
	Savepoint    bool
	KeysetCursor bool // keyset pagination needs no degradation

	// Gate layers (see cost.Gate assembly).
	ExplainJSON      bool // supports EXPLAIN ... JSON output
	ExplainCost      bool // EXPLAIN yields a numeric cost (SQLite does not)
	ExplainAccurate  bool // estimate trustworthiness (PG high; MySQL/OB medium; SQLite low)
	StatementTimeout bool // native timeout exists; core does not SET it across pooled connections
	ScanRowCap       bool // ob max_read_size / mysql max_join_size (runtime scan-row hard cap)
	SQLSafeUpdates   bool // mysql/ob sql_safe_updates (prevents full-table writes)
	ResourceManager  bool // ob tenant / oracle resource isolation
}

Capabilities declares what a database supports. It drives codegen rendering (e.g. RETURNING fallback) and which Gate layers are assembled (e.g. whether the Estimate layer is enabled, which DB-native limits apply). See the cost gate design.

type Dialect

type Dialect interface {
	Name() string
	QuoteIdent(name string) string
	Placeholder(index int) string
	ExplainSQL(query string) string
	Capabilities() Capabilities
}

Dialect abstracts the SQL differences core codegen needs. Implementations are stateless and safe for concurrent use.

Jump to

Keyboard shortcuts

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