dialect

package
v0.0.0-...-ae0b575 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CommonDataTypes = []string{
	"INT", "INTEGER", "BIGINT", "SMALLINT", "TINYINT",
	"DECIMAL", "NUMERIC", "FLOAT", "REAL", "DOUBLE",
	"CHAR", "VARCHAR", "TEXT", "NCHAR", "NVARCHAR",
	"DATE", "TIME", "DATETIME", "TIMESTAMP",
	"BOOLEAN", "BOOL", "BIT",
	"BLOB", "BINARY", "VARBINARY",
}

Common data types

View Source
var CommonKeywords = []string{
	"SELECT", "FROM", "WHERE", "JOIN", "INNER", "LEFT", "RIGHT", "FULL", "OUTER",
	"ON", "AS", "AND", "OR", "NOT", "IN", "EXISTS", "BETWEEN", "LIKE", "IS", "NULL",
	"INSERT", "INTO", "VALUES", "UPDATE", "SET", "DELETE", "CREATE", "TABLE", "INDEX",
	"DROP", "ALTER", "ADD", "COLUMN", "PRIMARY", "KEY", "FOREIGN", "REFERENCES",
	"UNIQUE", "CHECK", "DEFAULT", "AUTO_INCREMENT", "IDENTITY",
	"GROUP", "BY", "HAVING", "ORDER", "ASC", "DESC", "LIMIT", "OFFSET",
	"UNION", "ALL", "DISTINCT", "CASE", "WHEN", "THEN", "ELSE", "END",
	"CAST", "CONVERT", "COUNT", "SUM", "AVG", "MIN", "MAX",
}

Common keywords shared across most SQL dialects

Functions

This section is empty.

Types

type Dialect

type Dialect interface {
	// Name returns the dialect name
	Name() string

	// QuoteIdentifier returns the proper way to quote identifiers in this dialect
	QuoteIdentifier(identifier string) string

	// SupportsFeature checks if a feature is supported in this dialect
	SupportsFeature(feature Feature) bool

	// GetKeywords returns dialect-specific keywords
	GetKeywords() []string

	// GetDataTypes returns dialect-specific data types
	GetDataTypes() []string

	// IsReservedWord checks if a word is reserved in this dialect
	IsReservedWord(word string) bool

	// GetLimitSyntax returns the LIMIT clause syntax for this dialect
	GetLimitSyntax() LimitSyntax
}

Dialect represents a SQL dialect with its specific features and syntax

func GetDialect

func GetDialect(name string) Dialect

GetDialect returns the appropriate dialect implementation

type Feature

type Feature int

Feature represents SQL features that may vary between dialects

const (
	FeatureCTE Feature = iota
	FeatureWindowFunctions
	FeatureJSONSupport
	FeatureArraySupport
	FeatureRecursiveCTE
	FeaturePartitioning
	FeatureFullTextSearch
	FeatureXMLSupport
	FeatureUpsert
	FeatureReturningClause
)

type LimitSyntax

type LimitSyntax int

LimitSyntax represents different ways to limit results

const (
	LimitSyntaxStandard  LimitSyntax = iota // LIMIT n OFFSET m
	LimitSyntaxSQLServer                    // TOP n
	LimitSyntaxOracle                       // ROWNUM
)

type MySQLDialect

type MySQLDialect struct{}

MySQLDialect implements MySQL-specific features

func (*MySQLDialect) GetDataTypes

func (d *MySQLDialect) GetDataTypes() []string

func (*MySQLDialect) GetKeywords

func (d *MySQLDialect) GetKeywords() []string

func (*MySQLDialect) GetLimitSyntax

func (d *MySQLDialect) GetLimitSyntax() LimitSyntax

func (*MySQLDialect) IsReservedWord

func (d *MySQLDialect) IsReservedWord(word string) bool

func (*MySQLDialect) Name

func (d *MySQLDialect) Name() string

func (*MySQLDialect) QuoteIdentifier

func (d *MySQLDialect) QuoteIdentifier(identifier string) string

func (*MySQLDialect) SupportsFeature

func (d *MySQLDialect) SupportsFeature(feature Feature) bool

type OracleDialect

type OracleDialect struct{}

OracleDialect implements Oracle-specific features

func (*OracleDialect) GetDataTypes

func (d *OracleDialect) GetDataTypes() []string

func (*OracleDialect) GetKeywords

func (d *OracleDialect) GetKeywords() []string

func (*OracleDialect) GetLimitSyntax

func (d *OracleDialect) GetLimitSyntax() LimitSyntax

func (*OracleDialect) IsReservedWord

func (d *OracleDialect) IsReservedWord(word string) bool

func (*OracleDialect) Name

func (d *OracleDialect) Name() string

func (*OracleDialect) QuoteIdentifier

func (d *OracleDialect) QuoteIdentifier(identifier string) string

func (*OracleDialect) SupportsFeature

func (d *OracleDialect) SupportsFeature(feature Feature) bool

type PostgreSQLDialect

type PostgreSQLDialect struct{}

PostgreSQLDialect implements PostgreSQL-specific features

func (*PostgreSQLDialect) GetDataTypes

func (d *PostgreSQLDialect) GetDataTypes() []string

func (*PostgreSQLDialect) GetKeywords

func (d *PostgreSQLDialect) GetKeywords() []string

func (*PostgreSQLDialect) GetLimitSyntax

func (d *PostgreSQLDialect) GetLimitSyntax() LimitSyntax

func (*PostgreSQLDialect) IsReservedWord

func (d *PostgreSQLDialect) IsReservedWord(word string) bool

func (*PostgreSQLDialect) Name

func (d *PostgreSQLDialect) Name() string

func (*PostgreSQLDialect) QuoteIdentifier

func (d *PostgreSQLDialect) QuoteIdentifier(identifier string) string

func (*PostgreSQLDialect) SupportsFeature

func (d *PostgreSQLDialect) SupportsFeature(feature Feature) bool

type SQLServerDialect

type SQLServerDialect struct{}

SQLServerDialect implements SQL Server-specific features

func (*SQLServerDialect) GetDataTypes

func (d *SQLServerDialect) GetDataTypes() []string

func (*SQLServerDialect) GetKeywords

func (d *SQLServerDialect) GetKeywords() []string

func (*SQLServerDialect) GetLimitSyntax

func (d *SQLServerDialect) GetLimitSyntax() LimitSyntax

func (*SQLServerDialect) IsReservedWord

func (d *SQLServerDialect) IsReservedWord(word string) bool

func (*SQLServerDialect) Name

func (d *SQLServerDialect) Name() string

func (*SQLServerDialect) QuoteIdentifier

func (d *SQLServerDialect) QuoteIdentifier(identifier string) string

func (*SQLServerDialect) SupportsFeature

func (d *SQLServerDialect) SupportsFeature(feature Feature) bool

type SQLiteDialect

type SQLiteDialect struct{}

SQLiteDialect implements SQLite-specific features

func (*SQLiteDialect) GetDataTypes

func (d *SQLiteDialect) GetDataTypes() []string

func (*SQLiteDialect) GetKeywords

func (d *SQLiteDialect) GetKeywords() []string

func (*SQLiteDialect) GetLimitSyntax

func (d *SQLiteDialect) GetLimitSyntax() LimitSyntax

func (*SQLiteDialect) IsReservedWord

func (d *SQLiteDialect) IsReservedWord(word string) bool

func (*SQLiteDialect) Name

func (d *SQLiteDialect) Name() string

func (*SQLiteDialect) QuoteIdentifier

func (d *SQLiteDialect) QuoteIdentifier(identifier string) string

func (*SQLiteDialect) SupportsFeature

func (d *SQLiteDialect) SupportsFeature(feature Feature) bool

Jump to

Keyboard shortcuts

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