mysql

package
v3.6.0 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package mysql implements the MySQL SQL dialect for cel2sql.

Index

Constants

View Source
const (
	IndexTypeBTree    = "BTREE"
	IndexTypeFullText = "FULLTEXT"
)

MySQL index type constants.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dialect

type Dialect struct{}

Dialect implements dialect.Dialect for MySQL 8.0+.

func New

func New() *Dialect

New creates a new MySQL dialect.

func (*Dialect) ConvertRegex

func (d *Dialect) ConvertRegex(re2Pattern string) (string, bool, error)

ConvertRegex converts an RE2 regex pattern to MySQL-compatible format.

func (*Dialect) MaxIdentifierLength

func (d *Dialect) MaxIdentifierLength() int

MaxIdentifierLength returns the MySQL maximum identifier length (64).

func (*Dialect) Name

func (d *Dialect) Name() dialect.Name

Name returns the dialect name.

func (*Dialect) RecommendIndex

func (d *Dialect) RecommendIndex(pattern dialect.IndexPattern) *dialect.IndexRecommendation

RecommendIndex generates a MySQL-specific index recommendation for the given pattern. Returns nil if no applicable index exists for this pattern.

func (*Dialect) ReservedKeywords

func (d *Dialect) ReservedKeywords() map[string]bool

ReservedKeywords returns the set of reserved SQL keywords for MySQL.

func (*Dialect) SupportedPatterns

func (d *Dialect) SupportedPatterns() []dialect.PatternType

SupportedPatterns returns the pattern types supported by MySQL.

func (*Dialect) SupportsIndexAnalysis

func (d *Dialect) SupportsIndexAnalysis() bool

SupportsIndexAnalysis returns true as MySQL index analysis is supported.

func (*Dialect) SupportsJSONB

func (d *Dialect) SupportsJSONB() bool

SupportsJSONB returns false as MySQL has a single JSON type.

func (*Dialect) SupportsNativeArrays

func (d *Dialect) SupportsNativeArrays() bool

SupportsNativeArrays returns false as MySQL uses JSON arrays.

func (*Dialect) SupportsRegex

func (d *Dialect) SupportsRegex() bool

SupportsRegex returns true as MySQL 8.0+ supports ICU regex.

func (*Dialect) ValidateFieldName

func (d *Dialect) ValidateFieldName(name string) error

ValidateFieldName validates a field name against MySQL naming rules.

func (*Dialect) WriteArrayLength

func (d *Dialect) WriteArrayLength(w *strings.Builder, _ int, writeExpr func() error) error

WriteArrayLength writes JSON_LENGTH(expr) for MySQL.

func (*Dialect) WriteArrayLiteralClose

func (d *Dialect) WriteArrayLiteralClose(w *strings.Builder)

WriteArrayLiteralClose writes the MySQL JSON array literal closing.

func (*Dialect) WriteArrayLiteralOpen

func (d *Dialect) WriteArrayLiteralOpen(w *strings.Builder)

WriteArrayLiteralOpen writes the MySQL JSON array literal opening.

func (*Dialect) WriteArrayMembership

func (d *Dialect) WriteArrayMembership(w *strings.Builder, writeElem func() error, writeArray func() error) error

WriteArrayMembership writes a MySQL array membership test using JSON_CONTAINS.

func (*Dialect) WriteArraySubqueryExprClose

func (d *Dialect) WriteArraySubqueryExprClose(w *strings.Builder)

WriteArraySubqueryExprClose closes the JSON_ARRAYAGG aggregate function for MySQL.

func (*Dialect) WriteArraySubqueryOpen

func (d *Dialect) WriteArraySubqueryOpen(w *strings.Builder)

WriteArraySubqueryOpen writes (SELECT JSON_ARRAYAGG( for MySQL array subqueries.

func (*Dialect) WriteBytesLiteral

func (d *Dialect) WriteBytesLiteral(w *strings.Builder, value []byte) error

WriteBytesLiteral writes a MySQL hex-encoded byte literal (X'...').

func (*Dialect) WriteCastToNumeric

func (d *Dialect) WriteCastToNumeric(w *strings.Builder)

WriteCastToNumeric writes a MySQL numeric cast (CAST(... AS DECIMAL)).

func (*Dialect) WriteContains

func (d *Dialect) WriteContains(w *strings.Builder, writeHaystack, writeNeedle func() error) error

WriteContains writes LOCATE(needle, haystack) > 0 for MySQL.

func (*Dialect) WriteDuration

func (d *Dialect) WriteDuration(w *strings.Builder, value int64, unit string)

WriteDuration writes a MySQL INTERVAL literal.

func (*Dialect) WriteEmptyTypedArray

func (d *Dialect) WriteEmptyTypedArray(w *strings.Builder, _ string)

WriteEmptyTypedArray writes an empty MySQL JSON array.

func (*Dialect) WriteEpochExtract

func (d *Dialect) WriteEpochExtract(w *strings.Builder, writeExpr func() error) error

WriteEpochExtract writes UNIX_TIMESTAMP(expr) for MySQL.

func (*Dialect) WriteExtract

func (d *Dialect) WriteExtract(w *strings.Builder, part string, writeExpr func() error, writeTZ func() error) error

WriteExtract writes a MySQL EXTRACT expression with DOW conversion.

func (*Dialect) WriteInterval

func (d *Dialect) WriteInterval(w *strings.Builder, writeValue func() error, unit string) error

WriteInterval writes a MySQL INTERVAL expression.

func (*Dialect) WriteJSONArrayElements

func (d *Dialect) WriteJSONArrayElements(w *strings.Builder, _ bool, _ bool, writeExpr func() error) error

WriteJSONArrayElements writes MySQL JSON array expansion using JSON_TABLE.

func (*Dialect) WriteJSONArrayLength

func (d *Dialect) WriteJSONArrayLength(w *strings.Builder, writeExpr func() error) error

WriteJSONArrayLength writes COALESCE(JSON_LENGTH(expr), 0) for MySQL.

func (*Dialect) WriteJSONArrayMembership

func (d *Dialect) WriteJSONArrayMembership(w *strings.Builder, _ string, writeExpr func() error) error

WriteJSONArrayMembership writes MySQL JSON array membership using JSON_CONTAINS.

func (*Dialect) WriteJSONExistence

func (d *Dialect) WriteJSONExistence(w *strings.Builder, _ bool, fieldName string, writeBase func() error) error

WriteJSONExistence writes a MySQL JSON key existence check.

func (*Dialect) WriteJSONExtractPath

func (d *Dialect) WriteJSONExtractPath(w *strings.Builder, pathSegments []string, writeRoot func() error) error

WriteJSONExtractPath writes MySQL JSON path extraction using JSON_CONTAINS_PATH.

func (*Dialect) WriteJSONFieldAccess

func (d *Dialect) WriteJSONFieldAccess(w *strings.Builder, writeBase func() error, fieldName string, isFinal bool) error

WriteJSONFieldAccess writes MySQL JSON field access using JSON_EXTRACT/JSON_UNQUOTE.

func (*Dialect) WriteJoin

func (d *Dialect) WriteJoin(w *strings.Builder, writeArray, writeDelim func() error) error

WriteJoin writes MySQL array join using JSON_UNQUOTE/GROUP_CONCAT pattern.

func (*Dialect) WriteLikeEscape

func (d *Dialect) WriteLikeEscape(w *strings.Builder)

WriteLikeEscape writes the MySQL LIKE escape clause.

func (*Dialect) WriteListIndex

func (d *Dialect) WriteListIndex(w *strings.Builder, writeArray func() error, writeIndex func() error) error

WriteListIndex writes MySQL JSON array index access.

func (*Dialect) WriteListIndexConst

func (d *Dialect) WriteListIndexConst(w *strings.Builder, writeArray func() error, index int64) error

WriteListIndexConst writes MySQL JSON constant array index access.

func (*Dialect) WriteNestedJSONArrayMembership

func (d *Dialect) WriteNestedJSONArrayMembership(w *strings.Builder, writeExpr func() error) error

WriteNestedJSONArrayMembership writes MySQL nested JSON array membership.

func (*Dialect) WriteParamPlaceholder

func (d *Dialect) WriteParamPlaceholder(w *strings.Builder, _ int)

WriteParamPlaceholder writes a MySQL positional parameter (?).

func (*Dialect) WriteRegexMatch

func (d *Dialect) WriteRegexMatch(w *strings.Builder, writeTarget func() error, pattern string, _ bool) error

WriteRegexMatch writes a MySQL REGEXP match expression.

func (*Dialect) WriteSplit

func (d *Dialect) WriteSplit(w *strings.Builder, writeStr, writeDelim func() error) error

WriteSplit writes MySQL string split using SUBSTRING_INDEX pattern.

func (*Dialect) WriteSplitWithLimit

func (d *Dialect) WriteSplitWithLimit(w *strings.Builder, writeStr, writeDelim func() error, _ int64) error

WriteSplitWithLimit writes MySQL string split with limit.

func (*Dialect) WriteStringConcat

func (d *Dialect) WriteStringConcat(w *strings.Builder, writeLHS, writeRHS func() error) error

WriteStringConcat writes MySQL string concatenation using CONCAT().

func (*Dialect) WriteStringLiteral

func (d *Dialect) WriteStringLiteral(w *strings.Builder, value string)

WriteStringLiteral writes a MySQL string literal with ” escaping.

func (*Dialect) WriteStructClose

func (d *Dialect) WriteStructClose(w *strings.Builder)

WriteStructClose writes the MySQL struct literal closing.

func (*Dialect) WriteStructOpen

func (d *Dialect) WriteStructOpen(w *strings.Builder)

WriteStructOpen writes the MySQL struct literal opening.

func (*Dialect) WriteTimestampArithmetic

func (d *Dialect) WriteTimestampArithmetic(w *strings.Builder, op string, writeTS, writeDur func() error) error

WriteTimestampArithmetic writes MySQL timestamp arithmetic.

func (*Dialect) WriteTimestampCast

func (d *Dialect) WriteTimestampCast(w *strings.Builder, writeExpr func() error) error

WriteTimestampCast writes a MySQL CAST to DATETIME.

func (*Dialect) WriteTypeName

func (d *Dialect) WriteTypeName(w *strings.Builder, celTypeName string)

WriteTypeName writes a MySQL type name for CAST expressions.

func (*Dialect) WriteUnnest

func (d *Dialect) WriteUnnest(w *strings.Builder, writeSource func() error) error

WriteUnnest writes MySQL JSON_TABLE for array unnesting.

Jump to

Keyboard shortcuts

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