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

[FORMATTING] It does not work well whenever defining procedure and chand changing the delimiter #827

Closed
aryanthepain opened this issue Feb 2, 2025 · 1 comment
Labels

Comments

@aryanthepain
Copy link

Input data

Which SQL and options did you provide as input?

DELIMITER //

CREATE PROCEDURE register_student(
    IN student_name VARCHAR(25),
    IN student_photo BLOB,
    IN student_phone INT(10),
    IN student_password VARCHAR(20)
)
BEGIN
    DECLARE new_roll_number BIGINT;
    
    -- Insert student details
    INSERT INTO students (name, photo, Phone_no)
    VALUES (student_name, student_photo, student_phone);

    -- Get the last inserted Roll_number
    SET new_roll_number = LAST_INSERT_ID();

    -- Insert password entry
    INSERT INTO student_password (Roll_number, password)
    VALUES (new_roll_number, student_password);
    
END;
//

DELIMITER ;

Expected Output

DELIMITER //

CREATE PROCEDURE register_student(
    IN student_name VARCHAR(25),
    IN student_photo BLOB,
    IN student_phone INT(10),
    IN student_password VARCHAR(20)
)
BEGIN
    DECLARE new_roll_number BIGINT;
    
    -- Insert student details
    INSERT INTO students (name, photo, Phone_no)
    VALUES (student_name, student_photo, student_phone);

    -- Get the last inserted Roll_number
    SET new_roll_number = LAST_INSERT_ID();

    -- Insert password entry
    INSERT INTO student_password (Roll_number, password)
    VALUES (new_roll_number, student_password);
    
END;
//

DELIMITER ;

Actual Output

DELIMITER / / CREATE PROCEDURE register_student (
    IN student_name VARCHAR(25),
    IN student_photo BLOB,
    IN student_phone INT (10),
    IN student_password VARCHAR(20)
) BEGIN DECLARE new_roll_number BIGINT;

-- Insert student details
INSERT INTO
    students (name, photo, Phone_no)
VALUES
    (student_name, student_photo, student_phone);

-- Get the last inserted Roll_number
SET
    new_roll_number = LAST_INSERT_ID ();

-- Insert password entry
INSERT INTO
    student_password (Roll_number, password)
VALUES
    (new_roll_number, student_password);

END;

/ / DELIMITER;

Usage

  • How are you calling / using the library?
    in vscode
  • What SQL language(s) does this apply to?
    mysqlite
  • Which SQL Formatter version are you using?
    1.6.0
@nene
Copy link
Collaborator

nene commented Feb 2, 2025

This is duplicate of #184
Yes, changing the delimiter is not supported. And in general the support of procedural SQL is pretty poor.

Also read the FAQ about Prettier SQL VSCode extension.

@nene nene closed this as completed Feb 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants