You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ast/formatter: SQL Server table hints WITH (NOLOCK) are never rendered; SQL() also drops PIVOT #604
The parser stores SQL Server table hints in TableReference.TableHints, but no renderer emits them. ast.SQL() also drops TableReference.Pivot, which pkg/formatter renders correctly. Round-tripping SQL Server queries therefore silently removes locking hints and PIVOT clauses.
Reproduction
With gosqlx.ParseWithDialect(sql, "sqlserver") on main 61ca6c8:
SELECT * FROM t WITH (NOLOCK)
SQL(): SELECT * FROM t
FormatAST: SELECT * FROM t
gosqlx format: SELECT * FROM t
SELECT * FROM s PIVOT (SUM(amt) FOR q IN ([Q1], [Q2])) AS p
SQL(): SELECT * FROM s p
FormatAST: SELECT * FROM s PIVOT (SUM(amt) FOR q IN ([Q1], [Q2])) AS p (correct)
gosqlx format: SELECT * FROM s AS p
Expected: WITH (NOLOCK) and the PIVOT clause are kept by all renderers.
Notes
TableHints is declared at pkg/sql/ast/ast_clauses.go:144. It is not referenced in pkg/sql/ast/sql.go (writeTableRef, ~line 1963), pkg/formatter/render.go (tableRefSQL, line 1281) or the CLI formatTableReference.
writeTableRef in pkg/sql/ast/sql.go has no Pivot or Unpivot handling. Port the logic from pkg/formatter/render.go:1294-1330.
The CLI case is also listed in the CLI formatter umbrella issue.
Activity
fix(cli): render gosqlx format through pkg/formatter and refuse non-r…
fix(ast,formatter): render SQL Server table hints and PIVOT/UNPIVOT i…
fix(ast,formatter): render SQL Server table hints and PIVOT/UNPIVOT i…
fix(ast,formatter,parser): address adversarial review for #632
fix(cli): render gosqlx format through pkg/formatter and refuse non-r…
fix(cli): render gosqlx format through pkg/formatter and refuse non-r…