[libpostgresql-jdbc-java] 79/128: the driver will always return Maps for hstore columns

Emmanuel Bourg ebourg-guest at moszumanska.debian.org
Mon Jan 9 10:18:33 UTC 2017


This is an automated email from the git hooks/post-receive script.

ebourg-guest pushed a commit to annotated tag REL9_3_1100
in repository libpostgresql-jdbc-java.

commit b5656f336440a1b2fe5e6cceff47b982b14daacb
Author: Nick White <nwhite at palantir.com>
Date:   Fri Jun 28 21:44:53 2013 -0400

    the driver will always return Maps for hstore columns
---
 org/postgresql/jdbc2/TypeInfoCache.java        | 1 +
 org/postgresql/test/extensions/HStoreTest.java | 4 ++++
 2 files changed, 5 insertions(+)

diff --git a/org/postgresql/jdbc2/TypeInfoCache.java b/org/postgresql/jdbc2/TypeInfoCache.java
index 2e79758..2297c0a 100644
--- a/org/postgresql/jdbc2/TypeInfoCache.java
+++ b/org/postgresql/jdbc2/TypeInfoCache.java
@@ -132,6 +132,7 @@ public class TypeInfoCache implements TypeInfo {
             addCoreType(pgTypeName, oid, sqlType, javaClass, arrayOid);
         }
 
+        _pgNameToJavaClass.put("hstore", Map.class.getName());
     }
 
     public synchronized void addCoreType(String pgTypeName, Integer oid, Integer sqlType, String javaClass, Integer arrayOid)
diff --git a/org/postgresql/test/extensions/HStoreTest.java b/org/postgresql/test/extensions/HStoreTest.java
index 3f1567c..2cc4cb2 100644
--- a/org/postgresql/test/extensions/HStoreTest.java
+++ b/org/postgresql/test/extensions/HStoreTest.java
@@ -37,6 +37,7 @@ public class HStoreTest extends TestCase {
     public void testHStoreSelect() throws SQLException {
         PreparedStatement pstmt = _conn.prepareStatement("SELECT 'a=>1,b=>2'::hstore");
         ResultSet rs = pstmt.executeQuery();
+        assertEquals(Map.class.getName(), rs.getMetaData().getColumnClassName(1));
         assertTrue(rs.next());
         String str = rs.getString(1);
         if (!("\"a\"=>\"1\", \"b\"=>\"2\"".equals(str) || "\"b\"=>\"2\", \"a\"=>\"1\"".equals(str))) {
@@ -51,6 +52,7 @@ public class HStoreTest extends TestCase {
     public void testHStoreSelectNullValue() throws SQLException {
         PreparedStatement pstmt = _conn.prepareStatement("SELECT 'a=>NULL'::hstore");
         ResultSet rs = pstmt.executeQuery();
+        assertEquals(Map.class.getName(), rs.getMetaData().getColumnClassName(1));
         assertTrue(rs.next());
         assertEquals("\"a\"=>NULL", rs.getString(1));
         Map correct = Collections.singletonMap("a", null);
@@ -62,6 +64,7 @@ public class HStoreTest extends TestCase {
         PreparedStatement pstmt = _conn.prepareStatement("SELECT ?::text");
         pstmt.setObject(1, correct);
         ResultSet rs = pstmt.executeQuery();
+        assertEquals(String.class.getName(), rs.getMetaData().getColumnClassName(1));
         assertTrue(rs.next());
         assertEquals("\"a\"=>\"1\"", rs.getString(1));
     }
@@ -71,6 +74,7 @@ public class HStoreTest extends TestCase {
         PreparedStatement pstmt = _conn.prepareStatement("SELECT ?");
         pstmt.setObject(1, correct);
         ResultSet rs = pstmt.executeQuery();
+        assertEquals(Map.class.getName(), rs.getMetaData().getColumnClassName(1));
         assertTrue(rs.next());
         assertEquals(correct, rs.getObject(1));
         assertEquals("\"a\"=>\"t'e\ns\\\"t\"", rs.getString(1));

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/libpostgresql-jdbc-java.git



More information about the pkg-java-commits mailing list