dialect

package
v1.1.0 Latest Latest
Warning

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

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

Documentation

Overview

Package dialect provides SQL dialect definitions for the transpiler.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContainsQuoteCharacters added in v1.1.0

func ContainsQuoteCharacters(segment string) bool

ContainsQuoteCharacters returns true if the segment contains backticks, double quotes, or single quotes. These characters are used for identifier quoting and must not appear in raw variable names — the transpiler handles quoting automatically.

func NeedsQuoting added in v1.1.0

func NeedsQuoting(segment string) bool

NeedsQuoting returns true if an identifier segment requires quoting. A segment needs quoting if it starts with a digit or contains characters other than letters, digits, and underscores.

func QuoteIdentifierSegment added in v1.1.0

func QuoteIdentifierSegment(segment string, d Dialect) string

QuoteIdentifierSegment wraps a single identifier segment with dialect-appropriate quote characters. It also escapes any embedded quote characters within the segment.

  • BigQuery / Spanner / ClickHouse: backtick (`)
  • PostgreSQL / DuckDB: double quote (")

Types

type Dialect

type Dialect int

Dialect represents a SQL dialect that the transpiler can target.

const (
	// DialectUnspecified is the zero value, indicating no dialect was set.
	// This will cause an error if used - users must explicitly set a dialect.
	DialectUnspecified Dialect = iota

	// DialectBigQuery targets Google BigQuery SQL syntax.
	DialectBigQuery

	// DialectSpanner targets Google Cloud Spanner SQL syntax.
	DialectSpanner

	// DialectPostgreSQL targets PostgreSQL SQL syntax.
	DialectPostgreSQL

	// DialectDuckDB targets DuckDB SQL syntax.
	DialectDuckDB

	// DialectClickHouse targets ClickHouse SQL syntax.
	DialectClickHouse
)

func (Dialect) IsValid

func (d Dialect) IsValid() bool

IsValid returns true if the dialect is a valid, specified dialect.

func (Dialect) String

func (d Dialect) String() string

String returns the string representation of the dialect.

func (Dialect) Validate

func (d Dialect) Validate() error

Validate returns an error if the dialect is not valid.

Jump to

Keyboard shortcuts

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