nene / prettier-plugin-sql-cst

Prettier SQL plugin that uses sql-parser-cst
https://nene.github.io/prettier-sql-playground/
GNU General Public License v3.0
123 stars 7 forks source link

The MySQL statement was incorrectly formatted #30

Closed yanglbme closed 2 months ago

yanglbme commented 2 months ago

Hello, I have a MySQL statement as follows:

DELETE p2
FROM
    person AS p1
    JOIN person AS p2 ON p1.email = p2.email
WHERE
    p1.id < p2.id;

which was incorrectly formatted as:

DELETE FROM p2
FROM
    person AS p1
    JOIN person AS p2 ON p1.email = p2.email
WHERE p1.id < p2.id;

See https://leetcode.com/problems/delete-duplicate-emails/

nene commented 2 months ago

Well, I don't really know what you mean by "incorrect" here.

I guess you are referring to DELETE being replaced with DELETE FROM.

You can turn off this behavior by configuring sqlCanonicalSyntax: false.

yanglbme commented 2 months ago

Thank you very much, the issue has been resolved.