Documentation
¶
Overview ¶
Package formatter renders PostgreSQL statements as canonically-styled SQL text. It runs the input through the root sql package, walks each statement's AST, and emits a lowercase, leading-comma layout. Anything it can't render comes back as ErrUnsupportedStatement.
Index ¶
Constants ¶
const ErrUnsupportedStatement errs.Const = "unsupported statement"
ErrUnsupportedStatement is what you get when the formatter hits a statement kind it can't render. Match it with errors.Is, not by string.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Formatter ¶
type Formatter struct {
// contains filtered or unexported fields
}
Formatter renders SQL with a fixed indentation step. It's an immutable value: the methods take a value receiver and New hands back a value, so you can copy and share a Formatter freely.
func (Formatter) Format ¶
Format parses query and renders each statement, joining multiple ones with a blank line. A parse failure comes back unwrapped (it already carries sql.ErrParse); a statement we can't render yields ErrUnsupportedStatement.