sql-formatter-org / sql-formatter

A whitespace formatter for different query languages
https://sql-formatter-org.github.io/sql-formatter/
MIT License
2.37k stars 405 forks source link

[FORMATTING] MariaDB function call parenthesis spacing results in invalid MariaDB SQL #757

Closed theking2 closed 4 months ago

theking2 commented 4 months ago

Input data

Which SQL and options did you provide as input?

select
    group_concat(PHYSICIAN separator ' / ') Doktor
from
    invoice_physician
group by
    INVOICENR;

Expected Output

select
    group_concat(PHYSICIAN separator ' / ') Doktor
from
    invoice_physician
group by
    INVOICENR;

Actual Output

select
    group_concat (PHYSICIAN separator ' / ') Doktor
from
    invoice_physician
group by
    INVOICENR;

Usage

MariaDB does not like a space between GROUP_CONCAT and the (. Don't ask but using the formatter breaks my code here.

theking2 commented 4 months ago

See https://stackoverflow.com/questions/78765315/use-of-group-concat-results-in-error-1064?noredirect=1#comment138871662_78765315

theking2 commented 4 months ago

and ultimatily here https://mariadb.com/kb/en/parentheses/

nene commented 4 months ago

You're saying that you're using version 4.1.1. I suppose you're referring to the version of the VS Code plugin.

According to my testing, this bug does not exist in SQL Formatter. You can try it on the demo page.

The most likely cause is that you haven't selected MariaDB as the SQL dialect that you're formatting. See the FAQ.

nene commented 4 months ago

I'm closing this. Feel free to comment if the above does not solve your issue.

theking2 commented 4 months ago

I went to a number of SQL formatters lately and had not specified MariaDB as dialect for this one. After adding this to settings.json

    "SQL-Formatter-VSCode.dialect": "mariadb",

the problem went away. Thanks.