Skip to content

Sharding not support ZoneDateTime #33660

@fyeeme

Description

@fyeeme

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

image should be
 return resultSet.getObject(columnIndex, type);
image

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions