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

sunnianjun 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 0bb7d2c1b33 Refactor AbstractUnsupportedDatabaseMetaDataResultSet 
(#31873)
0bb7d2c1b33 is described below

commit 0bb7d2c1b33fd33039a92a5b41eb94eed69b9826
Author: Liang Zhang <[email protected]>
AuthorDate: Wed Jun 26 19:43:29 2024 +0800

    Refactor AbstractUnsupportedDatabaseMetaDataResultSet (#31873)
    
    * Refactor ShardingSphereResultSet
    
    * Refactor AbstractUnsupportedDatabaseMetaDataResultSet
    
    * Refactor AbstractUnsupportedDatabaseMetaDataResultSet
---
 .../driver/jdbc/core/resultset/ShardingSphereResultSet.java   | 11 +++++++++++
 .../AbstractUnsupportedDatabaseMetaDataResultSet.java         | 11 +++++++++++
 .../AbstractUnsupportedGeneratedKeysResultSet.java            | 11 +++++++++++
 .../unsupported/AbstractUnsupportedOperationResultSet.java    | 11 -----------
 .../state/circuit/resultset/CircuitBreakerResultSet.java      | 11 +++++++++++
 .../jdbc/unsupported/UnsupportedOperationResultSetTest.java   | 10 ----------
 6 files changed, 44 insertions(+), 21 deletions(-)

diff --git 
a/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/resultset/ShardingSphereResultSet.java
 
b/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/resultset/ShardingSphereResultSet.java
index 903b39f4fba..13044aa1f0b 100644
--- 
a/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/resultset/ShardingSphereResultSet.java
+++ 
b/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/resultset/ShardingSphereResultSet.java
@@ -34,6 +34,7 @@ import java.sql.Array;
 import java.sql.Blob;
 import java.sql.Clob;
 import java.sql.Date;
+import java.sql.NClob;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.SQLFeatureNotSupportedException;
@@ -330,6 +331,16 @@ public final class ShardingSphereResultSet extends 
AbstractResultSetAdapter {
         return getClob(getIndexFromColumnLabelAndIndexMap(columnLabel));
     }
     
+    @Override
+    public NClob getNClob(final int columnIndex) throws SQLException {
+        return (NClob) mergeResultSet.getValue(columnIndex, NClob.class);
+    }
+    
+    @Override
+    public NClob getNClob(final String columnLabel) throws SQLException {
+        return getNClob(getIndexFromColumnLabelAndIndexMap(columnLabel));
+    }
+    
     @Override
     public Array getArray(final int columnIndex) throws SQLException {
         return (Array) mergeResultSet.getValue(columnIndex, Array.class);
diff --git 
a/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/unsupported/AbstractUnsupportedDatabaseMetaDataResultSet.java
 
b/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/unsupported/AbstractUnsupportedDatabaseMetaDataResultSet.java
index b70fc73ff7d..7fa617069e6 100644
--- 
a/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/unsupported/AbstractUnsupportedDatabaseMetaDataResultSet.java
+++ 
b/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/unsupported/AbstractUnsupportedDatabaseMetaDataResultSet.java
@@ -23,6 +23,7 @@ import java.sql.Array;
 import java.sql.Blob;
 import java.sql.Clob;
 import java.sql.Date;
+import java.sql.NClob;
 import java.sql.SQLException;
 import java.sql.SQLFeatureNotSupportedException;
 import java.sql.SQLWarning;
@@ -116,6 +117,16 @@ public abstract class 
AbstractUnsupportedDatabaseMetaDataResultSet extends Abstr
         throw new SQLFeatureNotSupportedException("getClob");
     }
     
+    @Override
+    public final NClob getNClob(final int columnIndex) throws SQLException {
+        throw new SQLFeatureNotSupportedException("getNClob");
+    }
+    
+    @Override
+    public final NClob getNClob(final String columnLabel) throws SQLException {
+        throw new SQLFeatureNotSupportedException("getNClob");
+    }
+    
     @Override
     public final Date getDate(final int columnIndex, final Calendar cal) 
throws SQLException {
         throw new SQLFeatureNotSupportedException("getDate(int columnIndex, 
Calendar cal)");
diff --git 
a/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/unsupported/AbstractUnsupportedGeneratedKeysResultSet.java
 
b/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/unsupported/AbstractUnsupportedGeneratedKeysResultSet.java
index ee4efe7d16b..8125795b08d 100644
--- 
a/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/unsupported/AbstractUnsupportedGeneratedKeysResultSet.java
+++ 
b/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/unsupported/AbstractUnsupportedGeneratedKeysResultSet.java
@@ -24,6 +24,7 @@ import java.sql.Array;
 import java.sql.Blob;
 import java.sql.Clob;
 import java.sql.Date;
+import java.sql.NClob;
 import java.sql.SQLException;
 import java.sql.SQLFeatureNotSupportedException;
 import java.sql.SQLWarning;
@@ -207,6 +208,16 @@ public abstract class 
AbstractUnsupportedGeneratedKeysResultSet extends Abstract
         throw new SQLFeatureNotSupportedException("getClob");
     }
     
+    @Override
+    public final NClob getNClob(final int columnIndex) throws SQLException {
+        throw new SQLFeatureNotSupportedException("getNClob");
+    }
+    
+    @Override
+    public final NClob getNClob(final String columnLabel) throws SQLException {
+        throw new SQLFeatureNotSupportedException("getNClob");
+    }
+    
     @Override
     public final URL getURL(final int columnIndex) throws SQLException {
         throw new SQLFeatureNotSupportedException("getURL");
diff --git 
a/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/unsupported/AbstractUnsupportedOperationResultSet.java
 
b/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/unsupported/AbstractUnsupportedOperationResultSet.java
index 06cb2b075f0..a84b6f8b009 100644
--- 
a/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/unsupported/AbstractUnsupportedOperationResultSet.java
+++ 
b/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/unsupported/AbstractUnsupportedOperationResultSet.java
@@ -18,7 +18,6 @@
 package org.apache.shardingsphere.driver.jdbc.unsupported;
 
 import java.io.Reader;
-import java.sql.NClob;
 import java.sql.Ref;
 import java.sql.RowId;
 import java.sql.SQLException;
@@ -150,16 +149,6 @@ public abstract class 
AbstractUnsupportedOperationResultSet extends AbstractUnsu
         throw new SQLFeatureNotSupportedException("getHoldability");
     }
     
-    @Override
-    public final NClob getNClob(final int columnIndex) throws SQLException {
-        throw new SQLFeatureNotSupportedException("getNClob");
-    }
-    
-    @Override
-    public final NClob getNClob(final String columnLabel) throws SQLException {
-        throw new SQLFeatureNotSupportedException("getNClob");
-    }
-    
     @Override
     public final Reader getNCharacterStream(final int columnIndex) throws 
SQLException {
         throw new SQLFeatureNotSupportedException("getNCharacterStream");
diff --git 
a/jdbc/src/main/java/org/apache/shardingsphere/driver/state/circuit/resultset/CircuitBreakerResultSet.java
 
b/jdbc/src/main/java/org/apache/shardingsphere/driver/state/circuit/resultset/CircuitBreakerResultSet.java
index 679d6500103..71fa245a39f 100644
--- 
a/jdbc/src/main/java/org/apache/shardingsphere/driver/state/circuit/resultset/CircuitBreakerResultSet.java
+++ 
b/jdbc/src/main/java/org/apache/shardingsphere/driver/state/circuit/resultset/CircuitBreakerResultSet.java
@@ -27,6 +27,7 @@ import java.sql.Array;
 import java.sql.Blob;
 import java.sql.Clob;
 import java.sql.Date;
+import java.sql.NClob;
 import java.sql.ResultSet;
 import java.sql.ResultSetMetaData;
 import java.sql.SQLWarning;
@@ -368,6 +369,16 @@ public final class CircuitBreakerResultSet extends 
AbstractUnsupportedOperationR
         return null;
     }
     
+    @Override
+    public NClob getNClob(final int columnIndex) {
+        return null;
+    }
+    
+    @Override
+    public NClob getNClob(final String columnLabel) {
+        return null;
+    }
+    
     @Override
     public URL getURL(final int columnIndex) {
         return null;
diff --git 
a/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/unsupported/UnsupportedOperationResultSetTest.java
 
b/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/unsupported/UnsupportedOperationResultSetTest.java
index c03e8061257..79a21cb76ce 100644
--- 
a/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/unsupported/UnsupportedOperationResultSetTest.java
+++ 
b/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/unsupported/UnsupportedOperationResultSetTest.java
@@ -163,16 +163,6 @@ class UnsupportedOperationResultSetTest {
         assertThrows(SQLFeatureNotSupportedException.class, () -> 
shardingSphereResultSet.getHoldability());
     }
     
-    @Test
-    void assertGetNClobForColumnIndex() {
-        assertThrows(SQLFeatureNotSupportedException.class, () -> 
shardingSphereResultSet.getNClob(1));
-    }
-    
-    @Test
-    void assertGetNClobForColumnLabel() {
-        assertThrows(SQLFeatureNotSupportedException.class, () -> 
shardingSphereResultSet.getNClob("label"));
-    }
-    
     @Test
     void assertGetNCharacterStreamForColumnIndex() {
         assertThrows(SQLFeatureNotSupportedException.class, () -> 
shardingSphereResultSet.getNCharacterStream(1));

Reply via email to