ebean-orm / ebean-migration

DB Migration runner (similar to Flyway) which can be used standalone or with Ebean (run migrations on EbeanServer start)
Apache License 2.0
9 stars 5 forks source link

DdlParser does not handle end-of-line comments correctly #9

Closed ksperling closed 7 years ago

ksperling commented 7 years ago

I just noticed this when it was causing a statement from my migration not to run:

update blabla ...; -- something helpful
alter table ...

The comment ends up prepended to the second statement, turning it into a comment.

This patch just adds a test. Not sure what the best fix is, as just looking for a "--" anywhere in the line could also match in a quoted string (even though that is somewhat unlikely) or how exactly you want to handle it within stored procs.

A simple fix might be to to join multiple lines of a statement with "\n" rather than " ", so that if a comment does pass through subsequent lines don't get merged into the comment (which is what happened in my migration case) and the driver /db itself will handle it.

rbygrave commented 7 years ago

Good thanks. Yes, I think the simple "\n" line join makes good sense.