cockroachdb / cockroach

CockroachDB — the cloud native, distributed SQL database designed for high availability, effortless scale, and control over data placement.
https://www.cockroachlabs.com
Other
30.16k stars 3.82k forks source link

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

Open tigrato opened 14 hours ago

tigrato commented 14 hours ago

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

&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

blathers-crl[bot] commented 14 hours ago

Hi @tigrato, please add branch-* labels to identify which branch(es) this C-bug affects.

:owl: Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.

blathers-crl[bot] commented 14 hours ago

Hello, I am Blathers. I am here to help you get the issue triaged.

It looks like you have not filled out the issue in the format of any of our templates. To best assist you, we advise you to use one of these templates.

I have CC'd a few people who may be able to assist you:

If we have not gotten back to your issue within a few business days, you can try the following:

:owl: Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.