pgdesign v0.26.0 /internal/sqlutil
On this page

Package sqlutil provides a shared adapter between the sqlexpr parser and the diagnostic package for consistent parse-error-to-diagnostic conversion.

#internal/sqlutil

#internal/sqlutil

Package sqlutil provides a shared adapter between the sqlexpr parser and the diagnostic package for consistent parse-error-to-diagnostic conversion.

ParseExpr parses a SQL expression via sqlexpr.Parse and converts any ParseError into a diagnostic.Warning with position information. The returned diagnostic intentionally has no diagnostic code; consumers assign their own codes since the same parse failure means different things in different contexts (e.g., E213 for generated column validation, C001/C002 for codegen checks).

#ParseExpr

Go go
func ParseExpr(expr, context string) (sqlexpr.Node, *diagnostic.Diagnostic)

ParseExpr parses a SQL expression and returns the AST node. On failure, it returns a warning diagnostic with position information extracted from ParseError. The context string identifies the expression for error messages (e.g., "generated column users.full_name").

Search