MCPcopy Create free account
hub / github.com/ajitpratap0/GoSQLX / NewSQLFormatter

Function NewSQLFormatter

cmd/gosqlx/cmd/sql_formatter.go:45–57  ·  view source on GitHub ↗

NewSQLFormatter creates a new AST-based SQL formatter

(opts FormatterOptions)

Source from the content-addressed store, hash-verified

43
44// NewSQLFormatter creates a new AST-based SQL formatter
45func NewSQLFormatter(opts FormatterOptions) *SQLFormatter {
46 indent := opts.Indent
47 if indent == "" {
48 indent = " " // Default to 2 spaces
49 }
50
51 return &SQLFormatter{
52 indent: indent,
53 compact: opts.Compact,
54 uppercaseKw: opts.UppercaseKw,
55 alignColumns: opts.AlignColumns,
56 }
57}
58
59// Format formats an AST into properly indented SQL
60func (f *SQLFormatter) Format(astObj *ast.AST) (string, error) {

Calls

no outgoing calls