You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2022/08/26 15:25:27 UTC
[GitHub] [shardingsphere] linghengqian commented on a diff in pull request #20570: offsetDateTime convert failed bug fix
linghengqian commented on code in PR #20570:
URL: https://github.com/apache/shardingsphere/pull/20570#discussion_r956153648
##########
shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/execute/result/query/impl/driver/jdbc/type/util/ResultSetUtil.java:
##########
@@ -31,10 +31,7 @@
import java.sql.SQLFeatureNotSupportedException;
import java.sql.Time;
import java.sql.Timestamp;
-import java.time.LocalDate;
-import java.time.LocalDateTime;
-import java.time.LocalTime;
-import java.time.ZoneId;
+import java.time.*;
Review Comment:
Should be changed to single class import, which breaks CI.
##########
shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/resultset/ShardingSphereResultSet.java:
##########
@@ -407,7 +408,7 @@ public <T> T getObject(final int columnIndex, final Class<T> type) throws SQLExc
return (T) getBlob(columnIndex);
} else if (Clob.class.equals(type)) {
return (T) getClob(columnIndex);
- } else if (LocalDateTime.class.equals(type) || LocalDate.class.equals(type) || LocalTime.class.equals(type)) {
Review Comment:
The judgment condition of this piece is too complicated. I think it is better to judge only `java.time.temporal.TemporalAccessor`.
##########
shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/execute/result/query/impl/driver/jdbc/type/util/ResultSetUtil.java:
##########
@@ -148,6 +145,9 @@ private static Object convertTimestampValue(final Object value, final Class<?> c
if (LocalTime.class.equals(convertType)) {
return timestamp.toInstant().atZone(ZoneId.systemDefault()).toLocalTime();
}
+ if(OffsetDateTime.class.equals(convertType)){
+ return timestamp.toInstant().atZone(ZoneId.systemDefault()).toOffsetDateTime();
+ }
Review Comment:
Add a unit test?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org