Skip to content

Conversation

@openai0229
Copy link

Description:

During SQL formatting, it was discovered that the newline character was missing after a single-line comment (-- comment). This causes the formatted SQL to be incorrect .

Test:

CREATE TRIGGER before_employee_delete
BEFORE DELETE ON employees
FOR EACH ROW
BEGIN
    -- abcd
    IF EXISTS (SELECT 1 FROM orders WHERE employee_id = OLD.id) THEN
        SIGNAL SQLSTATE '45000'
        SET MESSAGE_TEXT = 'Cannot delete employee because they have related orders';
    END IF;
END;

Formatted Result Before the Fix:
image

Formatted Result After the Fix:
image


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license
and can be relicensed under the terms of the LGPL v2.1 license in the future at the maintainers' discretion.
For more information on licensing, please check here.


@hibernate-github-bot
Copy link

hibernate-github-bot bot commented Feb 18, 2025

Thanks for your pull request!

This pull request does not follow the contribution rules. Could you have a look?

❌ All commit messages should start with a JIRA issue key matching pattern HHH-\d+
    ↳ Offending commits: [a46aee7]

› This message was automatically generated.

@openai0229 openai0229 changed the title Fix SQL formatting bug where a newline is missing after a single-line… Fix SQL formatting bug where a newline is missing after a single-line Feb 18, 2025
@openai0229 openai0229 changed the title Fix SQL formatting bug where a newline is missing after a single-line Fix SQL formatting bug where a newline is missing after a single-line comment Feb 18, 2025
@gavinking
Copy link
Member

Looks reasonable.

@openai0229
Copy link
Author

Looks reasonable.

Do I need to add more test cases?

@beikov beikov merged commit 6874e0c into hibernate:main Feb 19, 2025
21 of 24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants