You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by xi...@apache.org on 2020/11/20 03:30:09 UTC

[shardingsphere] branch master updated: #7940, Data type column cast failed (#8234)

This is an automated email from the ASF dual-hosted git repository.

xiaoyu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new d62b6ba  #7940, Data type column cast failed (#8234)
d62b6ba is described below

commit d62b6ba1ca4b78ee9fd97bbdc268a2725e9af48e
Author: Zhang Yonglun <zh...@apache.org>
AuthorDate: Fri Nov 20 11:29:41 2020 +0800

    #7940, Data type column cast failed (#8234)
---
 .../query/binary/execute/protocol/MySQLDateBinaryProtocolValue.java    | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/query/binary/execute/protocol/MySQLDateBinaryProtocolValue.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/query/binary/execute/protocol/MySQLDateBinaryProtocolValue.java
index ed1d21a..8ced47b 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/query/binary/execute/protocol/MySQLDateBinaryProtocolValue.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/query/binary/execute/protocol/MySQLDateBinaryProtocolValue.java
@@ -23,6 +23,7 @@ import java.sql.SQLException;
 import java.sql.SQLFeatureNotSupportedException;
 import java.sql.Timestamp;
 import java.util.Calendar;
+import java.util.Date;
 
 /**
  * Binary protocol value for date for MySQL.
@@ -64,7 +65,7 @@ public final class MySQLDateBinaryProtocolValue implements MySQLBinaryProtocolVa
     
     @Override
     public void write(final MySQLPacketPayload payload, final Object value) {
-        Timestamp timestamp = (Timestamp) value;
+        Timestamp timestamp = new Timestamp(((Date) value).getTime());
         Calendar calendar = Calendar.getInstance();
         calendar.setTime(timestamp);
         int year = calendar.get(Calendar.YEAR);