Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sharding not support ZoneDateTime #33660

Closed
fyeeme opened this issue Nov 14, 2024 · 4 comments · Fixed by #33680
Closed

Sharding not support ZoneDateTime #33660

fyeeme opened this issue Nov 14, 2024 · 4 comments · Fixed by #33680

Comments

@fyeeme
Copy link
Contributor

fyeeme commented Nov 14, 2024

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.

@fyeeme
Copy link
Contributor Author

fyeeme commented Nov 14, 2024

relative issue,here #27968

@terrymanu
Copy link
Member

The CI are all broken, can you fix it?

@fyeeme
Copy link
Contributor Author

fyeeme commented Nov 15, 2024

Ok, I wil fix it asap

fyeeme added a commit to fyeeme/shardingsphere that referenced this issue Nov 15, 2024
fyeeme added a commit to fyeeme/shardingsphere that referenced this issue Nov 15, 2024
fyeeme added a commit to fyeeme/shardingsphere that referenced this issue Nov 15, 2024
terrymanu pushed a commit that referenced this issue Nov 16, 2024
* ResultSet support ZonedDateTime(#33660)

* Fix style(#33660)

* Fix UT && Compatibility(#33660)
@terrymanu
Copy link
Member

Well done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants