Hi,
I have the feeling DbUnit has issues retrieving tables when :
Affected versions : [2.5.3 - 2.7.3]
To reproduce
Use H2 as your database
DatabaseConfiguration :
setQualifiedTableNames(true);
setAllowEmptyFields(true);
setCaseSensitiveTableNames(false);
Create a XML dataset, prefixing the table name with a the schema name in lower case (for example myschema.MYTABLE)
Run a unit test
The exception is :
org.dbunit.dataset.NoSuchTableException: myschema.MYTABLE
at org.dbunit.database.DatabaseDataSet.getTableMetaData(DatabaseDataSet.java:305)
at org.dbunit.operation.DeleteAllOperation.execute(DeleteAllOperation.java:109)
at org.dbunit.operation.CompositeOperation.execute(CompositeOperation.java:79)
Additional information :
The framework we are using is Spring (we are using the dependency com.github.springtestdbunit:spring-test-dbunit:1.3.0)
We are using XML for defining our datasets
Writing the schema name in lowercase worked in previous versions (until the version 2.5.3)
I have the feeling that the problem occurs in the DatabaseDataset class, while extracting the ResultSet (line 118 in 2.7.3 version)
The schema registered in the metadata is in lowercase, while the real schema name is in upper case (because we set the property CaseSensitive to false)
So when we call the following method, nothing is returned
metadataHandler.getTables(databaseMetaData, schema, tableType) -> the variable schema here is in lower case
I remain at your disposal for any further information
Thank you for reporting this with the good details!
Other areas of the code uppercase the table names as needed, perhaps you encountered a spot missing that (just a guess).
If you could create a test that reproduces this and create merge request, it would help a lot [0] (some notes that may help [1]). Adding a fix if possible is really great too.
[0] https://sourceforge.net/p/dbunit/code.git/merge-requests/
[1] https://dbunit.sourceforge.net/dbunit/devguide.html
Last edit: Jeff Jensen 2022-11-24