You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2023/04/07 05:06:58 UTC

[shardingsphere] branch master updated: Add more fraction-of-seconds in PostgreSQLTextTimestampUtils (#25047)

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

zhaojinchao 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 b6bae465fc3 Add more fraction-of-seconds in PostgreSQLTextTimestampUtils (#25047)
b6bae465fc3 is described below

commit b6bae465fc3b38a6b5c47c40f71ca98bbe4e0284
Author: 吴伟杰 <wu...@apache.org>
AuthorDate: Fri Apr 7 13:06:51 2023 +0800

    Add more fraction-of-seconds in PostgreSQLTextTimestampUtils (#25047)
---
 .../bind/protocol/PostgreSQLTextTimestampUtils.java         |  2 +-
 .../bind/protocol/PostgreSQLTextTimestampUtilsTest.java     | 13 +++++++------
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLTextTimestampUtils.java b/db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLTextTimestampUtils.java
index a5e81137202..40ab6cb3dcb 100644
--- a/db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLTextTimestampUtils.java
+++ b/db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLTextTimestampUtils.java
@@ -38,7 +38,7 @@ public final class PostgreSQLTextTimestampUtils {
             "[yyyy-MM-dd][yyyy_MM_dd][yyyyMMdd][yyyy-M-d][MM/dd/yy][yyMMdd]"
                     + "['T'][ ]"
                     + "[HH:mm:ss][HHmmss][HH:mm][HHmm]"
-                    + "[.SSSSSS][.SSSSS][.SSSS][.SSS][.SS][.S]"
+                    + "[.SSSSSSSSS][.SSSSSSSS][.SSSSSSS][.SSSSSS][.SSSSS][.SSSS][.SSS][.SS][.S]"
                     + "[ ]"
                     + "[XXXXX][XXXX][XXX][XX][X]");
     
diff --git a/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLTextTimestampUtilsTest.java b/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLTextTimestampUtilsTest.java
index b8eebcf00f4..c0c5452a701 100644
--- a/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLTextTimestampUtilsTest.java
+++ b/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLTextTimestampUtilsTest.java
@@ -61,13 +61,14 @@ class PostgreSQLTextTimestampUtilsTest {
                     Arguments.of("2021-10-12 23:23:23.12345678", Timestamp.valueOf("2021-10-12 23:23:23.12345678")),
                     Arguments.of("2021-10-12 23:23:23.123456789", Timestamp.valueOf("2021-10-12 23:23:23.123456789")),
                     Arguments.of("2021-10-12 23:23:23.123456 +08:00", Timestamp.valueOf("2021-10-12 23:23:23.123456")),
-                    // TODO The following 4 cases are related to user.timezone of test environment
-                    // Arguments.of("2021-10-12 23:23:23.1234567 +08:00", Timestamp.valueOf("2021-10-12 23:23:23.1234567")),
-                    // Arguments.of("2021-10-12 23:23:23.12345678 +08:00", Timestamp.valueOf("2021-10-12 23:23:23.12345678")),
-                    // Arguments.of("2021-10-12 23:23:23.123456789+08:00", Timestamp.valueOf("2021-10-12 23:23:23.123456789")),
-                    // Arguments.of("2021-10-12 23:23:23.123456789 +08:00", Timestamp.valueOf("2021-10-12 23:23:23.123456789")),
+                    Arguments.of("2021-10-12 23:23:23.1234567 +08:00", Timestamp.valueOf("2021-10-12 23:23:23.1234567")),
+                    Arguments.of("2021-10-12 23:23:23.12345678 +08:00", Timestamp.valueOf("2021-10-12 23:23:23.12345678")),
+                    Arguments.of("2021-10-12 23:23:23.123456789+08:00", Timestamp.valueOf("2021-10-12 23:23:23.123456789")),
+                    Arguments.of("2021-10-12 23:23:23.123456789 +08:00", Timestamp.valueOf("2021-10-12 23:23:23.123456789")),
                     Arguments.of("2021-10-12 23:23:23.123456 -08:00", Timestamp.valueOf("2021-10-12 23:23:23.123456")),
-                    Arguments.of("2021-3-3 23:23:23.123456", Timestamp.valueOf("2021-03-03 23:23:23.123456")));
+                    Arguments.of("2021-3-3 23:23:23.123456", Timestamp.valueOf("2021-03-03 23:23:23.123456")),
+                    Arguments.of("infinity", new Timestamp(9223372036825200000L)),
+                    Arguments.of("-infinity", new Timestamp(-9223372036832400000L)));
         }
     }
 }