NewSQLFormatter creates a new AST-based SQL formatter
(opts FormatterOptions)
| 43 | |
| 44 | // NewSQLFormatter creates a new AST-based SQL formatter |
| 45 | func 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 |
| 60 | func (f *SQLFormatter) Format(astObj *ast.AST) (string, error) { |
no outgoing calls