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: fix tuple pretty print when tuple has 1 element #135938

Open tigrato opened 14 hours ago

tigrato commented 14 hours ago

When using sql/sem/tree.Tuple to generate SQL statements for IN operators, the produced output is incorrect if the tuple only has one element. The output includes an extra ,.

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.

This commit aims to fix these conditions and remove the trailing ,.

blathers-crl[bot] commented 14 hours ago

Thank you for contributing to CockroachDB. Please ensure you have followed the guidelines for creating a PR.

Before a member of our team reviews your PR, I have some potential action items for you:

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

cockroach-teamcity commented 14 hours ago

CLA assistant check
All committers have signed the CLA.

cockroach-teamcity commented 14 hours ago

This change is Reviewable

blathers-crl[bot] commented 14 hours ago

Thank you for updating your pull request.

Before a member of our team reviews your PR, I have some potential action items for you:

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