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

Function FormatSQLWithDialect

pkg/transform/transform.go:242–246  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

240// sql := transform.FormatSQLWithDialect(stmt, keywords.DialectSQLServer)
241// // "SELECT TOP 100 * FROM users"
242func 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

Calls 2

CompactStyleFunction · 0.92
FormatStatementFunction · 0.92