Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] preserve empty line between SQL blocks #914

Closed
1 of 5 tasks
loynoir opened this issue Jul 17, 2022 · 4 comments · Fixed by #996
Closed
1 of 5 tasks

[BUG] preserve empty line between SQL blocks #914

loynoir opened this issue Jul 17, 2022 · 4 comments · Fixed by #996

Comments

@loynoir
Copy link

loynoir commented Jul 17, 2022

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
    • MySQL/MariaDB
    • MSSQL/Azure
    • SQLite
    • Other? Which...
  • Database version: mysql 8.0.29

Additional context
DBeaver > select > Generate SQL > DDL

@loynoir loynoir added the triage label Jul 17, 2022
@loynoir
Copy link
Author

loynoir commented Jul 17, 2022

#507

@gjsjohnmurray
Copy link
Collaborator

Does #887 (comment) help you?

@martijnarts
Copy link

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.

@gjsjohnmurray
Copy link
Collaborator

gjsjohnmurray commented Sep 28, 2022

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;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants