You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SET
statement_timeout =0;
SET
lock_timeout =0;
SET
idle_in_transaction_session_timeout =0;
SET
transaction_timeout =0;
SET
client_encoding ='UTF8';
SET
standard_conforming_strings =on;
Wanted:
SET statement_timeout =0;
SET lock_timeout =0;
SET idle_in_transaction_session_timeout =0;
SET transaction_timeout =0;
SET client_encoding ='UTF8';
SET standard_conforming_strings =on;
Would be nice, yes. Unfortunately this happens because the formatter is unable to distinguish between SET in UPDATE ... SET and just plain SET. It does not understand context.
The same issue is with MySQL DEFAULT CHARACTER SET:
CREATE DATABASE test DEFAULT CHARACTER
SET
utf8mb4 COLLATE utf8mb4_0900_ai_ci;
CREATE TABLE
test.test (
id bigint NOT NULL AUTO_INCREMENT,
name varchar(255) DEFAULT NULL,
PRIMARY KEY (id)
) ENGINE = InnoDB DEFAULT CHARACTER
SET
= utf8mb4 COLLATE = utf8mb4_0900_ai_ci;
Same issue with DROP in the context of ALTER COLUMN column_name DROP NOT NULL. Presumably it's bugged for the same reason as SET as it assumes it's being used in the context of something like DROP TABLE table_name. If this does ever get fixed, could it be done so for DROP as well?
@KJlt77 you're either using an old version of sql-formatter or are not setting the dialect to MySQL. For me the above gets formatted as follows:
@nene I'm using SQL Formatter as an VSCode extension so it may be the issue with sql-formatter-vscode repo. I'm working with different SQL dialects so changing settings every time I open a different file is not an option.
Extension has a dialect's auto-detect and statements I provided have keywords specific to MySQL, like DEFAULT CHARACTER SET % COLLATE %, ENGINE = InnoDB, so it would be nice if the file would be detected as MySQL.
Setting/switching dialect with a comment in the file would be helpful too, though I failed to find such option.
Either way, thank you for your contribution to this project.
Activity
nene commentedon Sep 9, 2025
Would be nice, yes. Unfortunately this happens because the formatter is unable to distinguish between
SETinUPDATE ... SETand just plainSET. It does not understand context.So it's kinda unlikely to get fixed.
[-]Feature Request: avoid newlines for SET statements[/-][+]Avoid newlines for SET statements[/+]KJlt77 commentedon Dec 3, 2025
The same issue is with MySQL
DEFAULT CHARACTER SET:nene commentedon Dec 3, 2025
@KJlt77 you're either using an old version of sql-formatter or are not setting the dialect to MySQL. For me the above gets formatted as follows:
You can try it in here
jansg08 commentedon Jan 6, 2026
Same issue with
DROPin the context ofALTER COLUMN column_name DROP NOT NULL. Presumably it's bugged for the same reason asSETas it assumes it's being used in the context of something likeDROP TABLE table_name. If this does ever get fixed, could it be done so forDROPas well?KJlt77 commentedon Jan 9, 2026
@nene I'm using SQL Formatter as an VSCode extension so it may be the issue with
sql-formatter-vscoderepo. I'm working with different SQL dialects so changing settings every time I open a different file is not an option.Extension has a dialect's
auto-detectand statements I provided have keywords specific to MySQL, likeDEFAULT CHARACTER SET % COLLATE %,ENGINE = InnoDB, so it would be nice if the file would be detected as MySQL.Setting/switching dialect with a comment in the file would be helpful too, though I failed to find such option.
Either way, thank you for your contribution to this project.