Documentation
¶
Overview ¶
Package postgres implements the PostgreSQL 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, dimension 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(_ *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, typeName 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, isJSONB bool, asText bool, writeExpr func() error) error
- func (d *Dialect) WriteJSONArrayLength(w *strings.Builder, writeExpr func() error) error
- func (d *Dialect) WriteJSONArrayMembership(w *strings.Builder, jsonFunc string, writeExpr func() error) error
- func (d *Dialect) WriteJSONExistence(w *strings.Builder, isJSONB 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, paramIndex int)
- func (d *Dialect) WriteRegexMatch(w *strings.Builder, writeTarget func() error, pattern string, ...) error
- func (d *Dialect) WriteSplit(w *strings.Builder, writeStr, writeDelim func() error) error
- func (d *Dialect) WriteSplitWithLimit(w *strings.Builder, writeStr, writeDelim func() error, limit 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" IndexTypeGIN = "GIN" IndexTypeGIST = "GIST" )
PostgreSQL index type constants.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Dialect ¶
type Dialect struct{}
Dialect implements dialect.Dialect for PostgreSQL.
func (*Dialect) ConvertRegex ¶
ConvertRegex converts an RE2 regex pattern to PostgreSQL POSIX format.
func (*Dialect) MaxIdentifierLength ¶
MaxIdentifierLength returns the PostgreSQL maximum identifier length (63).
func (*Dialect) RecommendIndex ¶
func (d *Dialect) RecommendIndex(pattern dialect.IndexPattern) *dialect.IndexRecommendation
RecommendIndex generates a PostgreSQL-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 PostgreSQL.
func (*Dialect) SupportedPatterns ¶
func (d *Dialect) SupportedPatterns() []dialect.PatternType
SupportedPatterns returns all pattern types supported by PostgreSQL.
func (*Dialect) SupportsIndexAnalysis ¶
SupportsIndexAnalysis returns true as PostgreSQL index analysis is supported.
func (*Dialect) SupportsJSONB ¶
SupportsJSONB returns true as PostgreSQL has a distinct JSONB type.
func (*Dialect) SupportsNativeArrays ¶
SupportsNativeArrays returns true as PostgreSQL has native array types.
func (*Dialect) SupportsRegex ¶
SupportsRegex returns true as PostgreSQL supports POSIX regex matching.
func (*Dialect) ValidateFieldName ¶
ValidateFieldName validates a field name against PostgreSQL naming rules.
func (*Dialect) WriteArrayLength ¶
WriteArrayLength writes COALESCE(ARRAY_LENGTH(expr, dimension), 0) for PostgreSQL.
func (*Dialect) WriteArrayLiteralClose ¶
WriteArrayLiteralClose writes the PostgreSQL array literal closing (]).
func (*Dialect) WriteArrayLiteralOpen ¶
WriteArrayLiteralOpen writes the PostgreSQL array literal opening (ARRAY[).
func (*Dialect) WriteArrayMembership ¶
func (d *Dialect) WriteArrayMembership(w *strings.Builder, writeElem func() error, writeArray func() error) error
WriteArrayMembership writes a PostgreSQL array membership test using = ANY().
func (*Dialect) WriteArraySubqueryExprClose ¶
WriteArraySubqueryExprClose is a no-op for PostgreSQL (no wrapper around the expression).
func (*Dialect) WriteArraySubqueryOpen ¶
WriteArraySubqueryOpen writes ARRAY(SELECT for PostgreSQL.
func (*Dialect) WriteBytesLiteral ¶
WriteBytesLiteral writes a PostgreSQL hex-encoded byte literal.
func (*Dialect) WriteCastToNumeric ¶
WriteCastToNumeric writes a PostgreSQL numeric cast suffix (::numeric).
func (*Dialect) WriteContains ¶
WriteContains writes POSITION(needle IN haystack) > 0 for PostgreSQL.
func (*Dialect) WriteDuration ¶
WriteDuration writes a PostgreSQL INTERVAL literal (INTERVAL N UNIT).
func (*Dialect) WriteEmptyTypedArray ¶
WriteEmptyTypedArray writes an empty PostgreSQL typed array (ARRAY[]::type[]).
func (*Dialect) WriteEpochExtract ¶
WriteEpochExtract writes EXTRACT(EPOCH FROM expr)::bigint for PostgreSQL.
func (*Dialect) WriteExtract ¶
func (d *Dialect) WriteExtract(w *strings.Builder, part string, writeExpr func() error, writeTZ func() error) error
WriteExtract writes a PostgreSQL EXTRACT expression with DOW conversion.
func (*Dialect) WriteInterval ¶
WriteInterval writes a PostgreSQL INTERVAL expression (INTERVAL expr UNIT).
func (*Dialect) WriteJSONArrayElements ¶
func (d *Dialect) WriteJSONArrayElements(w *strings.Builder, isJSONB bool, asText bool, writeExpr func() error) error
WriteJSONArrayElements writes a PostgreSQL JSON array expansion function.
func (*Dialect) WriteJSONArrayLength ¶
WriteJSONArrayLength writes COALESCE(jsonb_array_length(expr), 0) for PostgreSQL.
func (*Dialect) WriteJSONArrayMembership ¶
func (d *Dialect) WriteJSONArrayMembership(w *strings.Builder, jsonFunc string, writeExpr func() error) error
WriteJSONArrayMembership writes ANY(ARRAY(SELECT json_func(expr))) for PostgreSQL.
func (*Dialect) WriteJSONExistence ¶
func (d *Dialect) WriteJSONExistence(w *strings.Builder, isJSONB bool, fieldName string, writeBase func() error) error
WriteJSONExistence writes a PostgreSQL JSON key existence check (? or IS NOT NULL).
func (*Dialect) WriteJSONExtractPath ¶
func (d *Dialect) WriteJSONExtractPath(w *strings.Builder, pathSegments []string, writeRoot func() error) error
WriteJSONExtractPath writes jsonb_extract_path_text() IS NOT NULL for PostgreSQL.
func (*Dialect) WriteJSONFieldAccess ¶
func (d *Dialect) WriteJSONFieldAccess(w *strings.Builder, writeBase func() error, fieldName string, isFinal bool) error
WriteJSONFieldAccess writes PostgreSQL JSON field access using -> or ->> operators.
func (*Dialect) WriteLikeEscape ¶
WriteLikeEscape writes the PostgreSQL LIKE escape clause.
func (*Dialect) WriteListIndex ¶
func (d *Dialect) WriteListIndex(w *strings.Builder, writeArray func() error, writeIndex func() error) error
WriteListIndex writes a PostgreSQL 1-indexed array access (array[index + 1]).
func (*Dialect) WriteListIndexConst ¶
func (d *Dialect) WriteListIndexConst(w *strings.Builder, writeArray func() error, index int64) error
WriteListIndexConst writes a PostgreSQL constant array index (0-indexed to 1-indexed).
func (*Dialect) WriteNestedJSONArrayMembership ¶
WriteNestedJSONArrayMembership writes ANY(ARRAY(SELECT jsonb_array_elements_text(expr))) for PostgreSQL.
func (*Dialect) WriteParamPlaceholder ¶
WriteParamPlaceholder writes a PostgreSQL positional parameter ($1, $2, ...).
func (*Dialect) WriteRegexMatch ¶
func (d *Dialect) WriteRegexMatch(w *strings.Builder, writeTarget func() error, pattern string, caseInsensitive bool) error
WriteRegexMatch writes a PostgreSQL regex match using ~ or ~* operators.
func (*Dialect) WriteSplit ¶
WriteSplit writes STRING_TO_ARRAY(string, delimiter) for PostgreSQL.
func (*Dialect) WriteSplitWithLimit ¶
func (d *Dialect) WriteSplitWithLimit(w *strings.Builder, writeStr, writeDelim func() error, limit int64) error
WriteSplitWithLimit writes (STRING_TO_ARRAY(string, delimiter))[1:limit] for PostgreSQL.
func (*Dialect) WriteStringConcat ¶
WriteStringConcat writes a PostgreSQL string concatenation using ||.
func (*Dialect) WriteStringLiteral ¶
WriteStringLiteral writes a PostgreSQL string literal with ” escaping.
func (*Dialect) WriteStructClose ¶
WriteStructClose writes the PostgreSQL struct/row literal closing ()).
func (*Dialect) WriteStructOpen ¶
WriteStructOpen writes the PostgreSQL struct/row literal opening (ROW().
func (*Dialect) WriteTimestampArithmetic ¶
func (d *Dialect) WriteTimestampArithmetic(w *strings.Builder, op string, writeTS, writeDur func() error) error
WriteTimestampArithmetic writes PostgreSQL timestamp arithmetic (timestamp +/- interval).
func (*Dialect) WriteTimestampCast ¶
WriteTimestampCast writes CAST(expr AS TIMESTAMP WITH TIME ZONE) for PostgreSQL.
func (*Dialect) WriteTypeName ¶
WriteTypeName writes a PostgreSQL type name for CAST expressions.