database-rider / database-rider

Database testing made easy!

Home Page:https://database-rider.github.io/database-rider

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot export H2 Dataset

trks1970 opened this issue · comments

When using the annotation:

@ExportDataSet(
         format = DataSetFormat.YML,
         outputName = "src/test/resources/dataset.yaml"
   )

with H2 (2.1.214) the following exception is thrown:

2022-11-06 19:24:49,246 - [ERROR] - [Test worker] c.g.d.r.c.e.DataSetExporter - Could not export dataset.
org.dbunit.dataset.DataSetException: org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "CONSTANTS" not found; SQL statement:
select CONSTANT_CATALOG, CONSTANT_SCHEMA, CONSTANT_NAME, VALUE_DEFINITION, DATA_TYPE, CHARACTER_MAXIMUM_LENGTH, CHARACTER_OCTET_LENGTH, CHARACTER_SET_CATALOG, CHARACTER_SET_SCHEMA, CHARACTER_SET_NAME, COLLATION_CATALOG, COLLATION_SCHEMA, COLLATION_NAME, NUMERIC_PRECISION, NUMERIC_PRECISION_RADIX, NUMERIC_SCALE, DATETIME_PRECISION, INTERVAL_TYPE, INTERVAL_PRECISION, MAXIMUM_CARDINALITY, DTD_IDENTIFIER, DECLARED_DATA_TYPE, DECLARED_NUMERIC_PRECISION, DECLARED_NUMERIC_SCALE, GEOMETRY_TYPE, GEOMETRY_SRID, REMARKS from CONSTANTS [42102-214]
	at org.dbunit.database.DatabaseDataSet.getTable(DatabaseDataSet.java:342)
	at org.dbunit.database.DatabaseTableIterator.getTable(DatabaseTableIterator.java:89)
	at org.dbunit.dataset.stream.DataSetProducerAdapter.produce(DataSetProducerAdapter.java:83)
	at com.github.database.rider.core.dataset.writer.YMLWriter.write(YMLWriter.java:117)
	at com.github.database.rider.core.exporter.DataSetExporter.export(DataSetExporter.java:144)
	at com.github.database.rider.core.RiderRunner.exportDataSet(RiderRunner.java:122)
	at com.github.database.rider.core.RiderRunner.teardown(RiderRunner.java:67)
	at com.github.database.rider.junit5.DBUnitExtension.afterTestExecution(DBUnitExtension.java:85)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeAfterTestExecutionCallbacks$9(TestMethodTestDescriptor.java:233)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeAllAfterMethodsOrCallbacks$13(TestMethodTestDescriptor.java:273)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeAllAfterMethodsOrCallbacks$14(TestMethodTestDescriptor.java:273)

Hi @trks1970, does it work with version 1.x of H2? In rider-core we use v2.x of H2
for the automated tests so I'd expect the export dataset tests to fail. Can you share a sample project which reproduces the issue? (Or if you can reproduce in rider core tests it's also fine).

Yes, it is working with H2 1.4.200.
Also fails with hsql 2.7.1
I am using rider-junit5 1.35.0.
I will create a project during the coming days, will get back to you.

Took more time than expected...
So, the solution is, that for H2 version 2.x it is required to specify schema in @DBUnit if it is present on the class.
@DBUnit(schema="PUBLIC")

if than is missing in the annotation, the exception above is thrown.

Thanks for the feedback @trks1970.