Describe the bug
If I execute DatabaseTester.setDataSet() and onSetup() with the dataset which includes timestamp with time zone column, the time zone of the data are effectively ignored, and inserted as if they were local time zone value.
It seems this occurs like :
- TimestampDataType::setSqlValue is invoked
- The value is converted into java.sql.Timestamp with typeCast() method.
typeCast() method shifts the timestamp value with both of time zones from dataset and local time zone, and returns Timestamp value which is translated into the same instant of local time zone.
- Calendar for time zone from dataset is created
- statement.setTimestamp() is called with the Timestamp and Calendar.
setTimestamp() internally clears the time zone shift from dataset which is calculated in step 2, and that will conclude into that as if the timestamp value in dataset was treated as local time zone and time zone in dataset is ignored.
To Reproduce
I've made a small project which reproduces the problem.
Please see this pull request which shows that DBUnit version 3.1.0 successes the test but 3.2.0 fails.
Steps to reproduce the behavior:
- dbUnit version
3.2.0
- Database vendor and version
H2 Database 2.4.240 with the reproduction project, and I've also checked with Oracle DB
- dbUnit data file rows and type
Requires timestamp with time zone column.
The time zone in the data must be different from the execution environment's time zone
- How run
Just run mvn test -Ddbunit.version=3.X.0 with the reproduction project.
If dbunit.version is 3.1.0, it will successfully be completed.
If dbunit.version is 3.2.0 or 3.3.0, it will fail.
Expected behavior
Timestamp data must be persisted with correct time zone.
Additional context
It seems it can be fixed by getting Calendar instance by Calendar.getInstance() with no parameter in TimestampDataType, but I'm not sure if it breaks other logics or other column types support like TIMESTAMP WITHOUT TIME ZONE or TIMESTAMP WITH LOCAL TIME ZONE.
Related issue: #711
Since this is the first time reporting the bug of OSS, and I'm not a mother tongue English speaker, so maybe this description is not enough understandable. Sorry for inconvenience.
Describe the bug
If I execute DatabaseTester.setDataSet() and onSetup() with the dataset which includes timestamp with time zone column, the time zone of the data are effectively ignored, and inserted as if they were local time zone value.
It seems this occurs like :
typeCast() method shifts the timestamp value with both of time zones from dataset and local time zone, and returns Timestamp value which is translated into the same instant of local time zone.
setTimestamp() internally clears the time zone shift from dataset which is calculated in step 2, and that will conclude into that as if the timestamp value in dataset was treated as local time zone and time zone in dataset is ignored.
To Reproduce
I've made a small project which reproduces the problem.
Please see this pull request which shows that DBUnit version 3.1.0 successes the test but 3.2.0 fails.
Steps to reproduce the behavior:
3.2.0
H2 Database 2.4.240 with the reproduction project, and I've also checked with Oracle DB
Requires timestamp with time zone column.
The time zone in the data must be different from the execution environment's time zone
Just run
mvn test -Ddbunit.version=3.X.0with the reproduction project.If dbunit.version is 3.1.0, it will successfully be completed.
If dbunit.version is 3.2.0 or 3.3.0, it will fail.
Expected behavior
Timestamp data must be persisted with correct time zone.
Additional context
It seems it can be fixed by getting Calendar instance by Calendar.getInstance() with no parameter in TimestampDataType, but I'm not sure if it breaks other logics or other column types support like TIMESTAMP WITHOUT TIME ZONE or TIMESTAMP WITH LOCAL TIME ZONE.
Related issue: #711
Since this is the first time reporting the bug of OSS, and I'm not a mother tongue English speaker, so maybe this description is not enough understandable. Sorry for inconvenience.