cockroachdb / cockroachdb/cockroach

sql/sem/tree: tuple pretty print generates invalid sql if tuple only has one element

Open
#135,939 2 comments 0 reactions 0 assignees View on GitHub
branch-master branch-release-24.3 C-bug O-community T-sql-foundations X-blathers-triaged
Dominant language
Go
Stars
32.5k
Forks
4.1k
PR merge metrics
PR metrics pending

Description

When using the tree package to generate SQL for tests using tuples, they generate incorrect SQL statements if the tuple only has one element.

As an example, the following

```go
&tree.Tuple{
Exprs: []tree.Expr{
tree.NewStrVal("val1"),
},
}

```

Is incorrectly mapped to `('val1',)` instead of `('val1')`.

Because of the extra `,`, sql parsers fail to parse the input.

Jira issue: CRDB-44797

Epic CRDB-60820

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.