Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix(ast): fix VALUES clause formatting to output multiple rows
The VALUES clause was incorrectly formatting multiple rows as a single
row with multiple columns. For example:
  VALUES ('A'), ('B'), ('C')
was being formatted as:
  VALUES ('A', 'B', 'C')

This caused the star expander to think the VALUES table had 3 columns
instead of 1, resulting in incorrect SELECT * expansion.

The fix properly iterates over each row in ValuesLists and wraps each
in parentheses.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
  • Loading branch information
kyleconroy and claude committed Dec 1, 2025
commit 32908436e881f6dca447fe9bfbd41c3f20ef0a05

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 10 additions & 3 deletions internal/sql/ast/select_stmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,16 @@ func (n *SelectStmt) Format(buf *TrackedBuffer, d format.Dialect) {
}

if items(n.ValuesLists) {
buf.WriteString("VALUES (")
buf.astFormat(n.ValuesLists, d)
buf.WriteString(")")
buf.WriteString("VALUES ")
// ValuesLists is a list of rows, where each row is a List of values
for i, row := range n.ValuesLists.Items {
if i > 0 {
buf.WriteString(", ")
}
buf.WriteString("(")
buf.astFormat(row, d)
buf.WriteString(")")
}
return
}

Expand Down
Loading