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

mbudiu pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/calcite-avatica.git


The following commit(s) were added to refs/heads/main by this push:
     new eccf6443b [CALCITE-6729] Ensure TypedValue allows sub-types for local 
representations
eccf6443b is described below

commit eccf6443b105f608a7beaed199f3fdb29c87829c
Author: Chris Dennis <[email protected]>
AuthorDate: Wed Dec 11 15:29:24 2024 -0500

    [CALCITE-6729] Ensure TypedValue allows sub-types for local representations
---
 .../java/org/apache/calcite/avatica/remote/TypedValue.java     |  2 +-
 .../java/org/apache/calcite/avatica/remote/TypedValueTest.java | 10 ++++++++++
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git 
a/core/src/main/java/org/apache/calcite/avatica/remote/TypedValue.java 
b/core/src/main/java/org/apache/calcite/avatica/remote/TypedValue.java
index 142a06b31..88506fcfa 100644
--- a/core/src/main/java/org/apache/calcite/avatica/remote/TypedValue.java
+++ b/core/src/main/java/org/apache/calcite/avatica/remote/TypedValue.java
@@ -269,7 +269,7 @@ public class TypedValue {
    * representation. */
   private static Object serialToLocal(ColumnMetaData.Rep rep, Object value) {
     assert value != null;
-    if (value.getClass() == rep.clazz) {
+    if (rep.clazz.isInstance(value)) {
       return value;
     }
     switch (rep) {
diff --git 
a/core/src/test/java/org/apache/calcite/avatica/remote/TypedValueTest.java 
b/core/src/test/java/org/apache/calcite/avatica/remote/TypedValueTest.java
index 335fa8a1a..cce081dde 100644
--- a/core/src/test/java/org/apache/calcite/avatica/remote/TypedValueTest.java
+++ b/core/src/test/java/org/apache/calcite/avatica/remote/TypedValueTest.java
@@ -44,6 +44,7 @@ import java.util.TimeZone;
 
 import static org.hamcrest.CoreMatchers.instanceOf;
 import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.sameInstance;
 import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
@@ -266,6 +267,15 @@ public class TypedValueTest {
     Object localObjCopy = tv1Copy.toLocal();
     assertTrue("The local object is an " + localObjCopy.getClass(), 
localObjCopy instanceof List);
   }
+
+  @Test public void testObjects() {
+    Object o1 = "This is a string";
+    TypedValue tv1 = TypedValue.ofJdbc(Rep.OBJECT, o1, Unsafe.localCalendar());
+    Object jdbcObj = tv1.toJdbc(Unsafe.localCalendar());
+    assertThat(jdbcObj, is(sameInstance(o1)));
+    Object localObj = tv1.toLocal();
+    assertThat(jdbcObj, is(sameInstance(o1)));
+  }
 }
 
 // End TypedValueTest.java

Reply via email to