dialect

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 27, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dialect

type Dialect interface {
	QuoteIdent(name string) string
	QuoteLiteral(v any) string
	Placeholder(n int) string
}

func New

func New(dataSourceName string) (Dialect, error)

type MySQL

type MySQL struct{}

func (MySQL) Placeholder

func (MySQL) Placeholder(_ int) string

func (MySQL) QuoteIdent

func (MySQL) QuoteIdent(name string) string

func (MySQL) QuoteLiteral

func (m MySQL) QuoteLiteral(v any) string

QuoteLiteral renders a Go value as a MySQL SQL literal. Strings escape `\` and `'` (MySQL interprets backslash sequences by default, unlike Postgres). Bytes use the hex literal form `X'..'`. Times are formatted as `'YYYY-MM-DD HH:MM:SS[.ffffff]'` in UTC; MySQL DATETIME / TIMESTAMP accept this for any precision up to microseconds. Unknown types fall back to fmt.Sprint and are quoted as strings.

type Postgres

type Postgres struct{}

func (Postgres) Placeholder

func (Postgres) Placeholder(n int) string

func (Postgres) QuoteIdent

func (Postgres) QuoteIdent(name string) string

func (Postgres) QuoteLiteral

func (p Postgres) QuoteLiteral(v any) string

QuoteLiteral renders a Go value as a Postgres SQL literal. Strings are single-quoted with `'` escaped by doubling (standard_conforming_strings is assumed on; backslashes are literal). Bytea uses the hex format (`'\x..'`). Times are RFC3339Nano with single quotes; Postgres parses that for DATE / TIMESTAMP / TIMESTAMPTZ alike. Unknown types fall back to fmt.Sprint and are quoted as strings.

Jump to

Keyboard shortcuts

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