vscode-sqltools icon indicating copy to clipboard operation
vscode-sqltools copied to clipboard

Formatter breaks procedure/function code

Open theking2 opened this issue 6 months ago • 1 comments

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 ;
  1. 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):

  • SQLTools Version v0.28.1
  • VS Code Version: 1.85.1
  • OS: Windows XP
  • Driver: n/a
  • Database version: MariaDB 11.1.2

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

theking2 avatar Dec 18 '23 11:12 theking2

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

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

gjsjohnmurray avatar Mar 26 '24 16:03 gjsjohnmurray