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

no space after sql comment dashes causes parse error on MySql #50

Closed
knight opened this issue May 7, 2014 · 3 comments
Closed

no space after sql comment dashes causes parse error on MySql #50

knight opened this issue May 7, 2014 · 3 comments

Comments

@knight
Copy link

knight commented May 7, 2014

If you write a migration in raw SQL format and include rollback statements or other adnotations using the -- Mysql fails to recognize it as comments. On the other hand if you introduce the mandatory space after the dashes liquibase does not recognize it as its valid statements.

Please take a look at: http://dev.mysql.com/doc/refman/5.5/en/ansi-diff-comments.html

@nvoxland
Copy link
Contributor

Is this an error with the hibernate extension? Or the general liquibase formatted sql support?

@scm6079
Copy link

scm6079 commented Aug 4, 2014

This issue is a general Liquibase SQL Changeset error.
In a Liquibase SQL change set, you must start with the comment "--liquibase formatted sql". Unfortunately, this is not a well-formed comment in MySQL. The comment must be "-- liquibase formatted sql". If you add the space to the liquibase comment, liquibase does not recognize it. If you continue without the space, all MySQL lint programs (e.g. Intelli-J, etc.) mark those lines as errors, and the scripts can not be executed with MySQL Workbench or other MySQL tools.

For example:

--liquibase formatted sql
--changeset smoore:20140730 dbms:mysql failOnError:true
CREATE TABLE example
(
    company_guid varchar(36) not null,
    anything varchar(80),
    create_ts datetime not null default now(),
    lastmod_ts datetime not null default now(),
    primary key( company_guid )
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--rollback DROP TABLE example;

Performing a syntax check (or execution) against MySQL returns:

13:55:22 --liquibase formatted sql
Error Code: 1064. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '--liquibase formatted sql' at line 1.

The fix would be to allow liquibase to recognize a space after the "--" in the comment. This is not related to liquibase-hibernate specifically at all.

@scm6079
Copy link

scm6079 commented Aug 4, 2014

This was addressed by CORE-1032.
https://liquibase.jira.com/browse/CORE-1032

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

No branches or pull requests

3 participants