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

DB2: MigrationTable is not found, when schema contains underscore #100

Closed rPraml closed 2 years ago

rPraml commented 2 years ago

We have found a weird issue, that tableExists() will not find an existing table, if the currentSchema URL parameter is less than 8 characters AND contains an underscore (Really?)

We tracked down the issue, and see, that connection.getSchema() always returns a string with minimum length of 8 chars. For jdbc:db2://localhost:50000/unit:currentSchema=Sch_2; it will return "Sch_2   " This string is passed into getTables which is effectively translated to CALL SYSIBM.SQLTABLES(?,?,?,?,?) by the JDBC driver

While CALL SYSIBM.SQLTABLES(null,'Sch1   ', null,null,null) will return all tables in Schema Sch1 (does not depend on spaces) The CALL SYSIBM.SQLTABLES(null,'Sch_1   ', null,null,null) will return nothing. While the CALL SYSIBM.SQLTABLES(null,'Sch_1', null,null,null) will return all tables of schema Sch_1

There are similar issues with underscore like this: https://www.ibm.com/support/pages/apar/PK48336

So as workaround, do not use underscores in schema names. We recommend to use max 8 chars, uppercase and no special chars in schema/db-name.

@rbygrave this is a problem with the DB2 driver/platform which can be easily avoided. Feel free to merge or decline this PR. Cheers Roland

rbygrave commented 2 years ago

We will merge it. Seems harmless enough for other drivers (to trim whitespace from the catalog and schema).