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

Allow the comment prefix used in data source initialisation scripts to be configured #16820

Closed
szumszym opened this issue May 10, 2019 · 3 comments
Labels
status: declined A suggestion or change that we don't feel we should currently apply

Comments

@szumszym
Copy link

szumszym commented May 10, 2019

Any line in the schema script with a sql comment and without semi-colon at the end of that line causes that the next sql statement is not executed but the rest of the script will be executed anyway.

Spring Boot v2.1.4.RELEASE

DOESNT' WORK:
DROP TABLE abc IF EXISTS;
# blablabla
DROP TABLE efg IF EXISTS;

DOES WORK:
DROP TABLE abc IF EXISTS;
# blablabla; <-- semi-colon added
DROP TABLE efg IF EXISTS;

(Please check if the issue occurs also for data.sql script)

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label May 10, 2019
@thackel
Copy link

thackel commented May 13, 2019

I am pretty sure SQL comments are only
-- line comment
and
/* block comment */
but not starting with #.

So just change your DDL to use correct SQL comments and it will work.

@wilkinsona
Copy link
Member

wilkinsona commented May 14, 2019

Spring Boot uses ResourceDatabasePopulator which is part of Spring Framework. By default, it uses -- for line comments and /* … */ for block comments. AIUI, these are the standard SQL comment types. Some databases, MySQL for example, also support # for line comments. The comment prefix used by ResourceDatabasePopulator can be configured, but Spring Boot does not expose this for its data source initialization. We can consider adding such a configuration option but I would recommend sticking with the standard SQL comment syntax.

@wilkinsona wilkinsona changed the title Schema (DDL) script (schema.sql) - incorrect parsing of sql comments Allow the comment prefix used in data source initialisations scripts to be configured May 14, 2019
@wilkinsona wilkinsona changed the title Allow the comment prefix used in data source initialisations scripts to be configured Allow the comment prefix used in data source initialisation scripts to be configured May 14, 2019
@wilkinsona wilkinsona added the type: enhancement A general enhancement label May 14, 2019
@philwebb
Copy link
Member

I think it's better that we keep ourselves aligned with the defaults in Spring Framework. A configuration option for such an edge case feels a bit too much. Only allowing standard SQL comments will also help keep scripts portable if developers ever choose to move to a different server.

@philwebb philwebb added status: declined A suggestion or change that we don't feel we should currently apply and removed status: waiting-for-triage An issue we've not yet triaged type: enhancement A general enhancement labels May 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: declined A suggestion or change that we don't feel we should currently apply
Projects
None yet
Development

No branches or pull requests

5 participants