-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Closed
Milestone
Description
Sharding not support ZoneDateTime
Which version of ShardingSphere did you use?
5.5.1
Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
ShardingSphere-JDBC
Expected behavior
zoneDateTime can be parsed correctly
Actual behavior
The field was parsed as LocalDateTime, which subsequently caused a conversion exception.
Caused by: java.lang.ClassCastException: class java.time.LocalDateTime cannot be cast to class java.time.ZonedDateTime (java.time.LocalDateTime and java.time.ZonedDateTime are in module java.base of loader 'bootstrap')
at org.apache.ibatis.type.ZonedDateTimeTypeHandler.getNullableResult(ZonedDateTimeTypeHandler.java:39)
at org.apache.ibatis.type.ZonedDateTimeTypeHandler.getNullableResult(ZonedDateTimeTypeHandler.java:29)
at org.apache.ibatis.type.BaseTypeHandler.getResult(BaseTypeHandler.java:86)
... 157 more
Reason analyze (If you can)
org.apache.shardingsphere.infra.executor.sql.execute.result.query.impl.driver.jdbc.type.stream.JDBCStreamQueryResult#getValue

return resultSet.getObject(columnIndex, type);

The type-specified resultSet.getObject supports parsing ZonedDateTime. However, in org.apache.shardingsphere.infra.executor.sql.execute.result.query.impl.driver.jdbc.type.stream.JDBCStreamQueryResult#getValue
, the method’s last line calls return resultSet.getObject(columnIndex); without specifying a type, resulting in ZonedDateTime parsing not being applied.
As a result, this method defaults to parsing database fields with dateTime types as LocalDateTime.