Closed mfickett closed 1 year ago
this error message, "Failed to execute database script from resource [-- It's not fine." (bolding is mine) doesn't actually match your test cases, which makes me think what you're testing isn't what you're editing ... or vice versa?
did you try / my comments and 'stuff here / rather than -- oneliner comment style? Is it possible that commentPrefix (which defaults to "--" is being over-ridden somewhere else? Grasping at (and then throwing) straws for you ...
I suspect this is because ScriptUtils#containsSqlScriptDelimiters does not take comments into consideration. So if the scripts contains a literal '
in a comment it can potentially lead to undesired behavior.
Nowadays, we are suggesting use withCopyFileToContainer
in MySQLContainer
and put the scripts under /docker-entrypoint-initdb.d
as is documented here. Also, given you are using Testcontainers JDBC URL we encourage to use Flyway or Liquibase.
I have a Kotlin Micronaut gRPC app that uses testcontainers via a datasource JDBC URL in its
application-test.yml
:If I use any of these contents for my
create_mydb_schema.sql
init script, the script is executed without error:I confirm that the script is being read with this line:
However, with this init script I get a syntax error:
(As a sanity check, I can do
source /path/to/.../src/test/create_mydb_schema.sql
with that contents and it's fine.)This also gets a syntax error: