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

SQL formatted changelogs mistakenly identify rollbackEndDelimiter value for endDelimiter value #5872

Open
2 tasks done
jasonlyle88 opened this issue May 2, 2024 · 2 comments · May be fixed by #5875
Open
2 tasks done
Labels

Comments

@jasonlyle88
Copy link
Contributor

jasonlyle88 commented May 2, 2024

Search first

  • I searched and no similar issues were found

Description

When using SQL formatted changelogs, Liquibase mistakenly identifies the rollbackEndDelimiter value for endDelimiter value when rollbackEndDelimiter is defined after the endDelimiter.

The issue is that the sql formatted changelog's changeset attributes are being parsed with regular expressions and endDelimiter is a substring of rollbackEndDelimiter. This allows the regex looking for endDelimiter to actually match on the rollbackEndDelimiter definition.

Steps To Reproduce

Run the following changelog. It will throw an error because the endDelimiter is not set to the correct value

--liquibase formatted sql

--changeset jlyle:mytest stripComments:false runOnChange:true runAlways:true endDelimiter:/ rollbackEndDelimiter:;

select 1 from sys.dual
/

select 1 from sys.dual
/

select 1 from sys.dual
/

begin
    null;
end;
/

Expected/Desired Behavior

endDelimiter and rollbackEndDelimiter to be able to be dfined correctly regardless of the order in which they are specified.

Liquibase Version

4.27.0

Database Vendor & Version

No response

Liquibase Integration

No response

Liquibase Extensions

No response

OS and/or Infrastructure Type/Provider

No response

Additional Context

The solution is simple, the src/main/java/liquibase/parser/AbstractFormattedChangeLogParser.java file just needs modified so changeset attributes look for a word boundary immediately before the attribute name. For example:

ROLLBACK_END_DELIMITER_REGEX = ".*rollbackEndDelimiter:(\\S*).*";

becomes

ROLLBACK_END_DELIMITER_REGEX = ".*\\brollbackEndDelimiter:(\\S*).*";

In order to avoid substring matching.

I am having some issues with my liquibase project setup right now I am trying to figure out. I will submit a PR as soon as I get those issues figured out. But this is super small, so if one of the team wants to grab it and get this handled, I wouldn't complain about that either!

Are you willing to submit a PR?

  • I'm willing to submit a PR (Thank you!)
@wwillard7800
Copy link
Contributor

Jason,

Thanks for the catch. We'll get this fixed up.

Wesley

@jasonlyle88
Copy link
Contributor Author

Awesome, thanks @wwillard7800 ! I've narrowed my issues down to 2 previous PRs and reached out to members involved there, so I'm hoping to be able to get back to contributing before too long!

wwillard7800 added a commit that referenced this issue May 3, 2024
Improve regex for endDelimiter and rollbackEndDelimiter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: In Development PR Issues
Development

Successfully merging a pull request may close this issue.

3 participants