Skip to content

Improve comment handling in ResourceDatabasePopulator [SPR-9261] #13899

@spring-projects-issues

Description

@spring-projects-issues

Lukas Kuster opened SPR-9261 and commented

The ResourceDatabasePopulator currently strips comments from an SQL file, but only if they start at the beginning of the line. If they are indented, or if they are placed on the same line after an SQL statement, they are left in the script and can be wrapped in with the following SQL statement, depending on the statement separator used.
E.g. in the following script, the comments at lines 2 and 3 would both be wrapped in with the insert statement on line 4, causing it to not be executed properly.

-- leading comment
insert into T_TEST (NAME) values ('Keith'); -- comment at EOL
	-- indented comment
insert into T_TEST (NAME) values ('Dave');

With the attached patch the ResourceDatabasePopulator removes all comments from an SQL file. A unit test illustrating the behaviour is included.


Affects: 3.1.1

Attachments:

Issue Links:

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)status: duplicateA duplicate of another issuetype: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions