mtxr / vscode-sqltools

Database management for VSCode
https://vscode-sqltools.mteixeira.dev?utm_source=github&utm_medium=homepage-link
MIT License
1.43k stars 290 forks source link

Formatter breaks procedure/function code #1261

Open theking2 opened 6 months ago

theking2 commented 6 months ago

Describe the bug Formatter breaks correct code for procedure/function definition

To Reproduce Steps to reproduce the behavior:

  1. original code
    DROP Procedure IF EXISTS `add`;
    DELIMITER $$
    CREATE DEFINER=`minidwh`@`localhost` PROCEDURE `add`(IN `a` INT, IN `b` INT, OUT `result` INT)
    BEGIN
    set result = a + b;
    END
    $$
    DELIMITER ;
  2. formatted code
    DROP Procedure IF EXISTS `add`;
    DELIMITER $$ CREATE DEFINER = `minidwh` @`localhost` PROCEDURE `add`(IN `a` INT, IN `b` INT, OUT `result` INT) BEGIN
    set result = a + b;
    END $$ DELIMITER;

Expected behavior This would be acceptable:

DROP Procedure IF EXISTS `add`;
DELIMITER $$
CREATE DEFINER = `minidwh` @`localhost` PROCEDURE `add`(
  IN `a` INT,
  IN `b` INT,
  OUT `result` INT)
BEGIN
  set result = a + b;
END $$
DELIMITER;

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Additional context This might have something to do with the DELIMITER problem

gjsjohnmurray commented 3 months ago

Workaround is to disable formatting by setting "sqltools.formatLanguages": [],

Please make sure you restart VS Code after you do this.