Formatted SQL with a comment.

I can’t get my comment added to the liquibase change log table.  File looks like this. The insert works but the comment is always getting inserted as a blank string. Any ideas on how to add this so it works? I also tried adding comment to the brackets with no luck like (comment:Test this out.)



–liquibase formatted sql

–changeset bob:REL01 (splitStatements:false endDelimiter::wink:
–comment TESTING OUT A COMMENT

DROP SCHEMA public;


–rollback CREATE SCHEMA public
–rollback  AUTHORIZATION postgres;

–rollbackGRANT ALL ON SCHEMA public TO postgres;
–rollbackGRANT ALL ON SCHEMA public TO public;
–rollbackCOMMENT ON SCHEMA public IS ‘standard public schema’;

Formatted SQL does not support a comment “tag” currently.  Your --comment is just seen as a commented SQL line and ignored.  The formattedSQL parser could easily be extended/improved to support it if you are interested in looking into it before I get to.


Nathan

Hi,

Is this functionality on the TODO list ?

Hi,

I’m a new user
And i would know if comments are available now ?

Thank you

Is this on the to do list?

It hasn’t made it yet, but I created https://liquibase.jira.com/browse/CORE-1422 now to track the feature request.


Nathan

I would really want this. Where in code to add?

The class that does the formatted SQL parsing is liquibase.parser.core.formattedsql.FormattedSqlParser. It is in src/main/java.


Let me know if you have questions on it. Any pull request are greatly appreciated.


Nathan

Hi Nathan,

I checked the jira ticket related to this, it seems it has been fixed in liquibase version 3.2.0, however I am not able to add comment via my formatted sql. Any ideas/sugestions?

Here’s how my formatted sql looks like:

–liquibase formatted sql

–changeset ascii:001

–comment CREATE TABLE

create table ascii (

id int primary key,</div>

name varchar(255)</div>

);

–rollback drop table ascii;

–changeset ascii:002

–comment INSERT TABLE

insert into ascii (id, name) values (1, ‘first’);

insert into ascii (id, name) values (2, ‘second’);

insert into ascii (id, name) values (3, ‘third’);

Am i missing something? I am running liquibase version 3.2.0.

It looks like it needs a “:” after --comment

–comment: INSERT TABLE

I put in a fix for 3.3.1 to make the colon optional.

Nathan

Adding a “:” works, thank you very much Nathan.

Here is my formatted sql that works:

$ cat ddl/test.sql

–liquibase formatted sql

–changeset ascii:001

–comment: Table for testing purposes

create table ascii (

id int primary key,</div>

name varchar(255)</div>

);

COMMENT ON COLUMN ascii.id IS ‘ID OF Employee’;

COMMENT ON COLUMN ascii.name IS ‘NAME OF Employee’;

–rollback drop table ascii;

–changeset ascii:002

–comment: Inserting test data

insert into ascii (id, name) values (1, ‘first’);

insert into ascii (id, name) values (2, ‘second’);

insert into ascii (id, name) values (3, ‘third’);