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

panjuan 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 296d2913d05 Fix #24889, support TINYINT in PostgreSQLColumnType. 
(#24890)
296d2913d05 is described below

commit 296d2913d05fbe88eb82ea460ac932ec97164825
Author: Raigor <[email protected]>
AuthorDate: Wed Mar 29 18:14:39 2023 +0800

    Fix #24889, support TINYINT in PostgreSQLColumnType. (#24890)
---
 .../query/extended/PostgreSQLColumnType.java       |   1 +
 .../query/extended/PostgreSQLColumnTypeTest.java   | 100 ++++++++++++++++++++-
 2 files changed, 99 insertions(+), 2 deletions(-)

diff --git 
a/db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/PostgreSQLColumnType.java
 
b/db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/PostgreSQLColumnType.java
index 681ef062a2c..64246486377 100644
--- 
a/db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/PostgreSQLColumnType.java
+++ 
b/db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/PostgreSQLColumnType.java
@@ -159,6 +159,7 @@ public enum PostgreSQLColumnType implements 
BinaryColumnType {
     private final int value;
     
     static {
+        JDBC_TYPE_AND_COLUMN_TYPE_MAP.put(Types.TINYINT, POSTGRESQL_TYPE_INT2);
         JDBC_TYPE_AND_COLUMN_TYPE_MAP.put(Types.SMALLINT, 
POSTGRESQL_TYPE_INT2);
         JDBC_TYPE_AND_COLUMN_TYPE_MAP.put(Types.INTEGER, POSTGRESQL_TYPE_INT4);
         JDBC_TYPE_AND_COLUMN_TYPE_MAP.put(Types.BIGINT, POSTGRESQL_TYPE_INT8);
diff --git 
a/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/PostgreSQLColumnTypeTest.java
 
b/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/PostgreSQLColumnTypeTest.java
index fed1a17cba5..ca39c5857e7 100644
--- 
a/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/PostgreSQLColumnTypeTest.java
+++ 
b/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/PostgreSQLColumnTypeTest.java
@@ -29,13 +29,109 @@ import static 
org.junit.jupiter.api.Assertions.assertThrows;
 class PostgreSQLColumnTypeTest {
     
     @Test
-    void assertValueOfJDBCType() {
+    void assertValueOfJDBCTypeForTinyint() {
+        PostgreSQLColumnType sqlColumnType = 
PostgreSQLColumnType.valueOfJDBCType(Types.TINYINT);
+        assertThat(sqlColumnType, 
is(PostgreSQLColumnType.POSTGRESQL_TYPE_INT2));
+    }
+    
+    @Test
+    void assertValueOfJDBCTypeForSmallint() {
+        PostgreSQLColumnType sqlColumnType = 
PostgreSQLColumnType.valueOfJDBCType(Types.SMALLINT);
+        assertThat(sqlColumnType, 
is(PostgreSQLColumnType.POSTGRESQL_TYPE_INT2));
+    }
+    
+    @Test
+    void assertValueOfJDBCTypeForInteger() {
+        PostgreSQLColumnType sqlColumnType = 
PostgreSQLColumnType.valueOfJDBCType(Types.INTEGER);
+        assertThat(sqlColumnType, 
is(PostgreSQLColumnType.POSTGRESQL_TYPE_INT4));
+    }
+    
+    @Test
+    void assertValueOfJDBCTypeForBigint() {
         PostgreSQLColumnType sqlColumnType = 
PostgreSQLColumnType.valueOfJDBCType(Types.BIGINT);
         assertThat(sqlColumnType, 
is(PostgreSQLColumnType.POSTGRESQL_TYPE_INT8));
     }
     
     @Test
-    void assertValueOfJDBCTypeForBooleanType() {
+    void assertValueOfJDBCTypeForNumeric() {
+        PostgreSQLColumnType sqlColumnType = 
PostgreSQLColumnType.valueOfJDBCType(Types.NUMERIC);
+        assertThat(sqlColumnType, 
is(PostgreSQLColumnType.POSTGRESQL_TYPE_NUMERIC));
+    }
+    
+    @Test
+    void assertValueOfJDBCTypeForDecimal() {
+        PostgreSQLColumnType sqlColumnType = 
PostgreSQLColumnType.valueOfJDBCType(Types.DECIMAL);
+        assertThat(sqlColumnType, 
is(PostgreSQLColumnType.POSTGRESQL_TYPE_NUMERIC));
+    }
+    
+    @Test
+    void assertValueOfJDBCTypeForReal() {
+        PostgreSQLColumnType sqlColumnType = 
PostgreSQLColumnType.valueOfJDBCType(Types.REAL);
+        assertThat(sqlColumnType, 
is(PostgreSQLColumnType.POSTGRESQL_TYPE_FLOAT4));
+    }
+    
+    @Test
+    void assertValueOfJDBCTypeForDouble() {
+        PostgreSQLColumnType sqlColumnType = 
PostgreSQLColumnType.valueOfJDBCType(Types.DOUBLE);
+        assertThat(sqlColumnType, 
is(PostgreSQLColumnType.POSTGRESQL_TYPE_FLOAT8));
+    }
+    
+    @Test
+    void assertValueOfJDBCTypeForChar() {
+        PostgreSQLColumnType sqlColumnType = 
PostgreSQLColumnType.valueOfJDBCType(Types.CHAR);
+        assertThat(sqlColumnType, 
is(PostgreSQLColumnType.POSTGRESQL_TYPE_CHAR));
+    }
+    
+    @Test
+    void assertValueOfJDBCTypeForVarchar() {
+        PostgreSQLColumnType sqlColumnType = 
PostgreSQLColumnType.valueOfJDBCType(Types.VARCHAR);
+        assertThat(sqlColumnType, 
is(PostgreSQLColumnType.POSTGRESQL_TYPE_VARCHAR));
+    }
+    
+    @Test
+    void assertValueOfJDBCTypeForBinary() {
+        PostgreSQLColumnType sqlColumnType = 
PostgreSQLColumnType.valueOfJDBCType(Types.BINARY);
+        assertThat(sqlColumnType, 
is(PostgreSQLColumnType.POSTGRESQL_TYPE_BYTEA));
+    }
+    
+    @Test
+    void assertValueOfJDBCTypeForBit() {
+        PostgreSQLColumnType sqlColumnType = 
PostgreSQLColumnType.valueOfJDBCType(Types.BIT);
+        assertThat(sqlColumnType, 
is(PostgreSQLColumnType.POSTGRESQL_TYPE_BIT));
+    }
+    
+    @Test
+    void assertValueOfJDBCTypeForDate() {
+        PostgreSQLColumnType sqlColumnType = 
PostgreSQLColumnType.valueOfJDBCType(Types.DATE);
+        assertThat(sqlColumnType, 
is(PostgreSQLColumnType.POSTGRESQL_TYPE_DATE));
+    }
+    
+    @Test
+    void assertValueOfJDBCTypeForTime() {
+        PostgreSQLColumnType sqlColumnType = 
PostgreSQLColumnType.valueOfJDBCType(Types.TIME);
+        assertThat(sqlColumnType, 
is(PostgreSQLColumnType.POSTGRESQL_TYPE_TIME));
+    }
+    
+    @Test
+    void assertValueOfJDBCTypeForTimestamp() {
+        PostgreSQLColumnType sqlColumnType = 
PostgreSQLColumnType.valueOfJDBCType(Types.TIMESTAMP);
+        assertThat(sqlColumnType, 
is(PostgreSQLColumnType.POSTGRESQL_TYPE_TIMESTAMP));
+    }
+    
+    @Test
+    void assertValueOfJDBCTypeForOther() {
+        PostgreSQLColumnType sqlColumnType = 
PostgreSQLColumnType.valueOfJDBCType(Types.OTHER);
+        assertThat(sqlColumnType, 
is(PostgreSQLColumnType.POSTGRESQL_TYPE_JSON));
+    }
+    
+    @Test
+    void assertValueOfJDBCTypeForSQLXML() {
+        PostgreSQLColumnType sqlColumnType = 
PostgreSQLColumnType.valueOfJDBCType(Types.SQLXML);
+        assertThat(sqlColumnType, 
is(PostgreSQLColumnType.POSTGRESQL_TYPE_XML));
+    }
+    
+    @Test
+    void assertValueOfJDBCTypeForBoolean() {
         PostgreSQLColumnType sqlColumnType = 
PostgreSQLColumnType.valueOfJDBCType(Types.BOOLEAN);
         assertThat(sqlColumnType, 
is(PostgreSQLColumnType.POSTGRESQL_TYPE_BOOL));
     }

Reply via email to