vscode-sqltools
vscode-sqltools copied to clipboard
[BUG] preserve empty line between SQL blocks
Describe the bug
linesBetweenQueries: preserve
but empty lines are removed.
To Reproduce
"sqltools.format": {
"linesBetweenQueries": "preserve"
}
CREATE TABLE `bar` (
`id` int NOT NULL,
`name` varchar(200) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
CREATE TABLE `foo` (
`id` int NOT NULL,
`name` varchar(200) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
CREATE TABLE `qaz` (
`id` int NOT NULL,
`name` varchar(200) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
Expected behavior
Empty line preserved when linesBetweenQueries: preserve
Actual behavior
Empty line removed when linesBetweenQueries: preserve
CREATE TABLE `bar` (
`id` int NOT NULL,
`name` varchar(200) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`)
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci;
CREATE TABLE `foo` (
`id` int NOT NULL,
`name` varchar(200) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`)
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci;
CREATE TABLE `qaz` (
`id` int NOT NULL,
`name` varchar(200) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`)
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci;
Screenshots If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
- SQLTools Version 0.23.0
- VSCode Version: 1.59.1
- OS: Linux
- Driver:
- [ ] PostgreSQL/Redshift
- [x] MySQL/MariaDB
- [ ] MSSQL/Azure
- [ ] SQLite
- [ ] Other? Which...
- Database version: mysql 8.0.29
Additional context DBeaver > select > Generate SQL > DDL
https://github.com/mtxr/vscode-sqltools/issues/507
Does https://github.com/mtxr/vscode-sqltools/discussions/887#discussioncomment-3009193 help you?
I'm finding the same. Trying to keep the line count preserved has very unpredictable behaviour, but always ends up in all blank lines being removed after a few saves.
Simple case:
SELECT 1 FROM contacts;
SELECT 2 FROM contacts;
SELECT 3 FROM contacts;
SELECT 4 FROM contacts;
After first format:
SELECT 1
FROM contacts;
SELECT 2
FROM contacts;
SELECT 3
FROM contacts;
SELECT 4
FROM contacts;
After second format:
SELECT 1
FROM contacts;
SELECT 2
FROM contacts;
SELECT 3
FROM contacts;
SELECT 4
FROM contacts;