testcontainers / testcontainers-java

Testcontainers is a Java library that supports JUnit tests, providing lightweight, throwaway instances of common databases, Selenium web browsers, or anything else that can run in a Docker container.
https://testcontainers.org
MIT License
7.99k stars 1.64k forks source link

Parsing of scripts containing the syllables "end" or "begin" is broken #1235

Open etluchs opened 5 years ago

etluchs commented 5 years ago

A script containing the syllable "end" (or, I suppose "begin") outside a comment or a quote will prevent the code from finding any further line-breaks, thus, usually breaking the script. the offending line is https://github.com/testcontainers/testcontainers-java/blob/b6de1ac6de2bc1a68c5a789661f48341f8cb858c/modules/database-commons/src/main/java/org/testcontainers/ext/ScriptUtils.java#L168

An example script would be

create tablespace DEV datafile 'dev.dbf' size 256M autoextend on;
CREATE USER bla IDENTIFIED BY testuser DEFAULT TABLESPACE DEV;
CREATE USER blub IDENTIFIED BY testuser DEFAULT TABLESPACE DEV;
CREATE USER bloh IDENTIFIED BY testuser DEFAULT TABLESPACE DEV;
kiview commented 5 years ago

Thanks for spotting this @etluchs. Can you already propose a better solution?

etluchs commented 5 years ago

Hm, one could hack it even more by only considering begin/end when found as whole words surrounded by whitespace equivalent. But I think, it might be worth biting the bullet and use some simple parser (generated with antlr or something).

kalexmills commented 5 years ago

This is affecting my project, since I'm trying to produce a schema which contains the word end in one of its columns... I'm moving back to 1.10.3 until this is fixed.

EDIT: Confirmed that using test containers at 1.10.3 fixes the issue for me. Others might use the same workaround.

rnorth commented 5 years ago

For now please work around by using the older version. This issue annoys me and is top of my list of bugs to fix. Apologies.

Sent with GitHawk

rrhartjr commented 5 years ago

Any updates on this? Looks like any substring of end causes a failure.. including 'gender' :(

ivankovbas commented 4 years ago

I've just checked on version 1.12.2 and it seems the issue is already fixed, so it could be closed. @rnorth isn't it?

rrhartjr commented 4 years ago

I confirmed it fails on 1.11.4 and works on 1.12.2, we have upgraded our dependency to 1.12.2, so I'm satisfied :)