Documentation
¶
Overview ¶
Package mysql implements the MySQL SQL dialect for cel2sql.
Index ¶
- Constants
- type Dialect
- func (d *Dialect) ConvertRegex(re2Pattern string) (string, bool, error)
- func (d *Dialect) MaxIdentifierLength() int
- func (d *Dialect) Name() dialect.Name
- func (d *Dialect) RecommendIndex(pattern dialect.IndexPattern) *dialect.IndexRecommendation
- func (d *Dialect) ReservedKeywords() map[string]bool
- func (d *Dialect) SupportedPatterns() []dialect.PatternType
- func (d *Dialect) SupportsIndexAnalysis() bool
- func (d *Dialect) SupportsJSONB() bool
- func (d *Dialect) SupportsNativeArrays() bool
- func (d *Dialect) SupportsRegex() bool
- func (d *Dialect) ValidateFieldName(name string) error
- func (d *Dialect) WriteArrayLength(w *strings.Builder, _ int, writeExpr func() error) error
- func (d *Dialect) WriteArrayLiteralClose(w *strings.Builder)
- func (d *Dialect) WriteArrayLiteralOpen(w *strings.Builder)
- func (d *Dialect) WriteArrayMembership(w *strings.Builder, writeElem func() error, writeArray func() error) error
- func (d *Dialect) WriteArraySubqueryExprClose(w *strings.Builder)
- func (d *Dialect) WriteArraySubqueryOpen(w *strings.Builder)
- func (d *Dialect) WriteBytesLiteral(w *strings.Builder, value []byte) error
- func (d *Dialect) WriteCastToNumeric(w *strings.Builder)
- func (d *Dialect) WriteContains(w *strings.Builder, writeHaystack, writeNeedle func() error) error
- func (d *Dialect) WriteDuration(w *strings.Builder, value int64, unit string)
- func (d *Dialect) WriteEmptyTypedArray(w *strings.Builder, _ string)
- func (d *Dialect) WriteEpochExtract(w *strings.Builder, writeExpr func() error) error
- func (d *Dialect) WriteExtract(w *strings.Builder, part string, writeExpr func() error, writeTZ func() error) error
- func (d *Dialect) WriteInterval(w *strings.Builder, writeValue func() error, unit string) error
- func (d *Dialect) WriteJSONArrayElements(w *strings.Builder, _ bool, _ bool, writeExpr func() error) error
- func (d *Dialect) WriteJSONArrayLength(w *strings.Builder, writeExpr func() error) error
- func (d *Dialect) WriteJSONArrayMembership(w *strings.Builder, _ string, writeExpr func() error) error
- func (d *Dialect) WriteJSONExistence(w *strings.Builder, _ bool, fieldName string, writeBase func() error) error
- func (d *Dialect) WriteJSONExtractPath(w *strings.Builder, pathSegments []string, writeRoot func() error) error
- func (d *Dialect) WriteJSONFieldAccess(w *strings.Builder, writeBase func() error, fieldName string, isFinal bool) error
- func (d *Dialect) WriteJoin(w *strings.Builder, writeArray, writeDelim func() error) error
- func (d *Dialect) WriteLikeEscape(w *strings.Builder)
- func (d *Dialect) WriteListIndex(w *strings.Builder, writeArray func() error, writeIndex func() error) error
- func (d *Dialect) WriteListIndexConst(w *strings.Builder, writeArray func() error, index int64) error
- func (d *Dialect) WriteNestedJSONArrayMembership(w *strings.Builder, writeExpr func() error) error
- func (d *Dialect) WriteParamPlaceholder(w *strings.Builder, _ int)
- func (d *Dialect) WriteRegexMatch(w *strings.Builder, writeTarget func() error, pattern string, _ bool) error
- func (d *Dialect) WriteSplit(w *strings.Builder, writeStr, writeDelim func() error) error
- func (d *Dialect) WriteSplitWithLimit(w *strings.Builder, writeStr, writeDelim func() error, _ int64) error
- func (d *Dialect) WriteStringConcat(w *strings.Builder, writeLHS, writeRHS func() error) error
- func (d *Dialect) WriteStringLiteral(w *strings.Builder, value string)
- func (d *Dialect) WriteStructClose(w *strings.Builder)
- func (d *Dialect) WriteStructOpen(w *strings.Builder)
- func (d *Dialect) WriteTimestampArithmetic(w *strings.Builder, op string, writeTS, writeDur func() error) error
- func (d *Dialect) WriteTimestampCast(w *strings.Builder, writeExpr func() error) error
- func (d *Dialect) WriteTypeName(w *strings.Builder, celTypeName string)
- func (d *Dialect) WriteUnnest(w *strings.Builder, writeSource func() error) error
Constants ¶
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 (*Dialect) ConvertRegex ¶
ConvertRegex converts an RE2 regex pattern to MySQL-compatible format.
func (*Dialect) MaxIdentifierLength ¶
MaxIdentifierLength returns the MySQL maximum identifier length (64).
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 ¶
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 ¶
SupportsIndexAnalysis returns true as MySQL index analysis is supported.
func (*Dialect) SupportsJSONB ¶
SupportsJSONB returns false as MySQL has a single JSON type.
func (*Dialect) SupportsNativeArrays ¶
SupportsNativeArrays returns false as MySQL uses JSON arrays.
func (*Dialect) SupportsRegex ¶
SupportsRegex returns true as MySQL 8.0+ supports ICU regex.
func (*Dialect) ValidateFieldName ¶
ValidateFieldName validates a field name against MySQL naming rules.
func (*Dialect) WriteArrayLength ¶
WriteArrayLength writes JSON_LENGTH(expr) for MySQL.
func (*Dialect) WriteArrayLiteralClose ¶
WriteArrayLiteralClose writes the MySQL JSON array literal closing.
func (*Dialect) WriteArrayLiteralOpen ¶
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 ¶
WriteArraySubqueryExprClose closes the JSON_ARRAYAGG aggregate function for MySQL.
func (*Dialect) WriteArraySubqueryOpen ¶
WriteArraySubqueryOpen writes (SELECT JSON_ARRAYAGG( for MySQL array subqueries.
func (*Dialect) WriteBytesLiteral ¶
WriteBytesLiteral writes a MySQL hex-encoded byte literal (X'...').
func (*Dialect) WriteCastToNumeric ¶
WriteCastToNumeric writes a MySQL numeric cast (CAST(... AS DECIMAL)).
func (*Dialect) WriteContains ¶
WriteContains writes LOCATE(needle, haystack) > 0 for MySQL.
func (*Dialect) WriteDuration ¶
WriteDuration writes a MySQL INTERVAL literal.
func (*Dialect) WriteEmptyTypedArray ¶
WriteEmptyTypedArray writes an empty MySQL JSON array.
func (*Dialect) WriteEpochExtract ¶
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 ¶
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 ¶
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 ¶
WriteJoin writes MySQL array join using JSON_UNQUOTE/GROUP_CONCAT pattern.
func (*Dialect) WriteLikeEscape ¶
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 ¶
WriteNestedJSONArrayMembership writes MySQL nested JSON array membership.
func (*Dialect) WriteParamPlaceholder ¶
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 ¶
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 ¶
WriteStringConcat writes MySQL string concatenation using CONCAT().
func (*Dialect) WriteStringLiteral ¶
WriteStringLiteral writes a MySQL string literal with ” escaping.
func (*Dialect) WriteStructClose ¶
WriteStructClose writes the MySQL struct literal closing.
func (*Dialect) WriteStructOpen ¶
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 ¶
WriteTimestampCast writes a MySQL CAST to DATETIME.
func (*Dialect) WriteTypeName ¶
WriteTypeName writes a MySQL type name for CAST expressions.