Menu

#447 NoSuchTableException when schama name written in lower case

v2.7.*
open-accepted
None
(not fixed)
5
2022-11-24
2022-11-24
Evgueni C.
No

Hi,

I have the feeling DbUnit has issues retrieving tables when :

  1. CaseSensitive property is set to false (default)
    and
  2. The schema name prefixing the table name is in lower case (for example : myschema.MYTABLE)

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

Discussion

  • Jeff Jensen

    Jeff Jensen - 2022-11-24
    • status: open --> open-accepted
    • assigned_to: Jeff Jensen
     
  • Jeff Jensen

    Jeff Jensen - 2022-11-24

    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).

    I remain at your disposal for any further information

    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

Log in to post a comment.

MongoDB Logo MongoDB