liquibase comments in sql formatted changelogs

1.2k views Asked by At

I have a requirement to retain Oracle SQL comments made inside my Liquibase sql formatted changelogs. Thus I have the following attribute set stripComments:false

Such comments in my SQL formatted changelogs are typically supplied using the standard -- (hyphen hyphen) characters

-- DROP LINK

However, it appears that with Liquibase attempts to execute all comments, and in this example, the comment above. This causes my Liquibase update to fail with the following error:

Invalid SQL type: sqlKind = UNINITIALIZED

I have tried to replcae all occurances of -- comment with /* comment */ but this also generates the same error.

Anyone have any ideas?

1

There are 1 answers

2
Jens On

You can check out StringUtils's stripComments() method for how liquibase identifies comments in your SQL.

There are regex patterns defined for this:

  1. "\\s*\\-\\-.*\\n"
  2. "\\s*\\-\\-.*$"
  3. "/\\*.*?\\*/"

You could take those patterns and put it in some online regex page (e.g. https://regex101.com/) along with your SQLs and see where it goes wrong.