FormatSQLWithDialect converts an AST statement back into a compact SQL string using dialect-specific syntax for row-limiting clauses (TOP for SQL Server, FETCH FIRST for Oracle, LIMIT for PostgreSQL/MySQL/etc.). Pass keywords.DialectGeneric or an empty SQLDialect for generic behavior identical to F
(stmt ast.Statement, dialect keywords.SQLDialect)
| 240 | // sql := transform.FormatSQLWithDialect(stmt, keywords.DialectSQLServer) |
| 241 | // // "SELECT TOP 100 * FROM users" |
| 242 | func FormatSQLWithDialect(stmt ast.Statement, dialect keywords.SQLDialect) string { |
| 243 | opts := ast.CompactStyle() |
| 244 | opts.Dialect = string(dialect) |
| 245 | return formatter.FormatStatement(stmt, opts) |
| 246 | } |
| 247 | |
| 248 | // ParseSQLWithDialect parses a SQL string using dialect-specific tokenization and |
| 249 | // parsing rules. This enables correct handling of dialect-specific syntax such as |