dialect

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package dialect abstracts per-RDBMS placeholder generation and literal formatting (for the /*^ */ literal directive). bisql abstracts only this; it does not handle SQL dialects themselves.

Index

Constants

This section is empty.

Variables

View Source
var (
	// MySQL uses ? placeholders.
	MySQL = Dialect{/* contains filtered or unexported fields */}
	// SQLite uses ? placeholders (positional), like MySQL.
	SQLite = Dialect{/* contains filtered or unexported fields */}
	// PostgreSQL uses $1, $2, ... placeholders and renders array literals as '{...}'.
	PostgreSQL = Dialect{
				// contains filtered or unexported fields
	}
	// Oracle uses :1, :2, ... placeholders.
	Oracle = Dialect{/* contains filtered or unexported fields */}
	// SQLServer uses @p1, @p2, ... placeholders.
	SQLServer = Dialect{/* contains filtered or unexported fields */}
)

Functions

func FormatLiteral

func FormatLiteral(v any) (string, error)

FormatLiteral is the default literal formatter: nil -> null, strings are single-quoted with ” escaping, booleans and numbers render bare. It is deliberately conservative; dialects with different quoting rules can supply their own.

Types

type Dialect

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

Dialect carries a name, its placeholder generator, and its literal formatter.

func (Dialect) Literal

func (d Dialect) Literal() Literal

Literal returns the literal formatter, falling back to FormatLiteral when unset.

func (Dialect) Name

func (d Dialect) Name() string

Name returns the dialect name.

func (Dialect) Placeholder

func (d Dialect) Placeholder() Placeholder

Placeholder returns the placeholder generator.

type Literal

type Literal func(v any) (string, error)

Literal formats a Go value as an inline SQL literal, for the /*^ */ directive.

type Placeholder

type Placeholder func(index int, name string) string

Placeholder generates a placeholder. index is the 1-based sequential number; name is the bind name (empty if anonymous).

Jump to

Keyboard shortcuts

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