# Formatted SQL with a comment.

**URL:** <https://forum.liquibase.org/t/formatted-sql-with-a-comment/1159>\
**Category:** General Discussion\
**Created:** [March 8, 2011, 3:50am UTC](https://forum.liquibase.org/t/formatted-sql-with-a-comment/1159 "2011-03-08T03:50:00Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![theoriginalbob](https://avatars.discourse-cdn.com/v4/letter/t/4bbf92/32.png) [@theoriginalbob](https://forum.liquibase.org/u/theoriginalbob)\
**Post date:** [March 8, 2011, 3:50am UTC](https://forum.liquibase.org/t/formatted-sql-with-a-comment/1159/1 "2011-03-08T03:50:00Z")

</div>

I can’t get my comment added to the liquibase change log table.&nbsp; 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:😉   
–comment TESTING OUT A COMMENT  
  
DROP SCHEMA public;  
  
  
–rollback CREATE SCHEMA public  
–rollback&nbsp; AUTHORIZATION postgres;  
  
–rollbackGRANT ALL ON SCHEMA public TO postgres;  
–rollbackGRANT ALL ON SCHEMA public TO public;  
–rollbackCOMMENT ON SCHEMA public IS ‘standard public schema’;

---

<div class="post-metadata">

**Author:** ![nvoxland](https://avatars.discourse-cdn.com/v4/letter/n/87869e/32.png) [@nvoxland](https://forum.liquibase.org/u/nvoxland)\
**Post date:** [March 8, 2011, 3:50am UTC](https://forum.liquibase.org/t/formatted-sql-with-a-comment/1159/2 "2011-03-08T03:50:00Z")

</div>

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

Nathan

---

<div class="post-metadata">

**Author:** ![Guest](https://avatars.discourse-cdn.com/v4/letter/g/8dc957/32.png) [@Guest](https://forum.liquibase.org/u/Guest)\
**Post date:** [March 8, 2011, 3:50am UTC](https://forum.liquibase.org/t/formatted-sql-with-a-comment/1159/3 "2011-03-08T03:50:00Z")

</div>

Hi,  
  
Is this functionality on the TODO list ?

---

<div class="post-metadata">

**Author:** ![Guest](https://avatars.discourse-cdn.com/v4/letter/g/8dc957/32.png) [@Guest](https://forum.liquibase.org/u/Guest)\
**Post date:** [March 8, 2011, 3:50am UTC](https://forum.liquibase.org/t/formatted-sql-with-a-comment/1159/4 "2011-03-08T03:50:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Guest](https://avatars.discourse-cdn.com/v4/letter/g/8dc957/32.png) [@Guest](https://forum.liquibase.org/u/Guest)\
**Post date:** [March 8, 2011, 3:50am UTC](https://forum.liquibase.org/t/formatted-sql-with-a-comment/1159/5 "2011-03-08T03:50:00Z")

</div>

Is this on the to do list?

---

<div class="post-metadata">

**Author:** ![nvoxland](https://avatars.discourse-cdn.com/v4/letter/n/87869e/32.png) [@nvoxland](https://forum.liquibase.org/u/nvoxland)\
**Post date:** [March 8, 2011, 3:50am UTC](https://forum.liquibase.org/t/formatted-sql-with-a-comment/1159/6 "2011-03-08T03:50:00Z")

</div>

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

Nathan

---

<div class="post-metadata">

**Author:** ![Guest](https://avatars.discourse-cdn.com/v4/letter/g/8dc957/32.png) [@Guest](https://forum.liquibase.org/u/Guest)\
**Post date:** [March 8, 2011, 3:50am UTC](https://forum.liquibase.org/t/formatted-sql-with-a-comment/1159/7 "2011-03-08T03:50:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![nvoxland](https://avatars.discourse-cdn.com/v4/letter/n/87869e/32.png) [@nvoxland](https://forum.liquibase.org/u/nvoxland)\
**Post date:** [March 8, 2011, 3:50am UTC](https://forum.liquibase.org/t/formatted-sql-with-a-comment/1159/8 "2011-03-08T03:50:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![un1415009322370r50id](https://avatars.discourse-cdn.com/v4/letter/u/f07891/32.png) [@un1415009322370r50id](https://forum.liquibase.org/u/un1415009322370r50id)\
**Post date:** [March 8, 2011, 3:50am UTC](https://forum.liquibase.org/t/formatted-sql-with-a-comment/1159/9 "2011-03-08T03:50:00Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![nvoxland](https://avatars.discourse-cdn.com/v4/letter/n/87869e/32.png) [@nvoxland](https://forum.liquibase.org/u/nvoxland)\
**Post date:** [March 8, 2011, 3:50am UTC](https://forum.liquibase.org/t/formatted-sql-with-a-comment/1159/10 "2011-03-08T03:50:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![un1415009322370r50id](https://avatars.discourse-cdn.com/v4/letter/u/f07891/32.png) [@un1415009322370r50id](https://forum.liquibase.org/u/un1415009322370r50id)\
**Post date:** [March 8, 2011, 3:50am UTC](https://forum.liquibase.org/t/formatted-sql-with-a-comment/1159/11 "2011-03-08T03:50:00Z")

</div>

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’);
