[libpostgresql-jdbc-java] 83/128: Make PreparedStatement.getObject() for an enum type return a string rather than a PGObject
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 0da850b49d343fb975dc7026944cf5e1b68e8c81
Author: Tom Dunstan <github at tomd.cc>
Date: Sun Jul 7 16:20:41 2013 +0930
Make PreparedStatement.getObject() for an enum type return a string rather than a PGObject
---
org/postgresql/jdbc2/AbstractJdbc2DatabaseMetaData.java | 4 +++-
org/postgresql/jdbc2/TypeInfoCache.java | 2 ++
org/postgresql/test/jdbc3/StringTypeParameterTest.java | 16 +++++++++++++---
3 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/org/postgresql/jdbc2/AbstractJdbc2DatabaseMetaData.java b/org/postgresql/jdbc2/AbstractJdbc2DatabaseMetaData.java
index 82c47f0..675eead 100644
--- a/org/postgresql/jdbc2/AbstractJdbc2DatabaseMetaData.java
+++ b/org/postgresql/jdbc2/AbstractJdbc2DatabaseMetaData.java
@@ -1847,7 +1847,7 @@ public abstract class AbstractJdbc2DatabaseMetaData
}
// decide if we are returning a single column result.
- if (returnTypeType.equals("b") || returnTypeType.equals("d") || (returnTypeType.equals("p") && argModesArray == null))
+ if (returnTypeType.equals("b") || returnTypeType.equals("d") || returnTypeType.equals("e") || (returnTypeType.equals("p") && argModesArray == null))
{
byte[][] tuple = new byte[columns][];
tuple[0] = null;
@@ -2464,6 +2464,8 @@ public abstract class AbstractJdbc2DatabaseMetaData
sqlType = Types.STRUCT;
} else if ("d".equals(typtype)) {
sqlType = Types.DISTINCT;
+ } else if ("e".equals(typtype)) {
+ sqlType = Types.VARCHAR;
} else {
sqlType = connection.getTypeInfo().getSQLType(typeOid);
}
diff --git a/org/postgresql/jdbc2/TypeInfoCache.java b/org/postgresql/jdbc2/TypeInfoCache.java
index b14b5c1..a68e0c0 100644
--- a/org/postgresql/jdbc2/TypeInfoCache.java
+++ b/org/postgresql/jdbc2/TypeInfoCache.java
@@ -231,6 +231,8 @@ public class TypeInfoCache implements TypeInfo {
type = new Integer(Types.STRUCT);
} else if ("d".equals(typtype)) {
type = new Integer(Types.DISTINCT);
+ } else if ("e".equals(typtype)) {
+ type = new Integer(Types.VARCHAR);
}
}
diff --git a/org/postgresql/test/jdbc3/StringTypeParameterTest.java b/org/postgresql/test/jdbc3/StringTypeParameterTest.java
index 1b887d3..2653c86 100644
--- a/org/postgresql/test/jdbc3/StringTypeParameterTest.java
+++ b/org/postgresql/test/jdbc3/StringTypeParameterTest.java
@@ -98,8 +98,12 @@ public class StringTypeParameterTest extends TestCase {
query.clearParameters();
query.setObject(1, "happy", Types.OTHER);
- query.executeQuery().close();
+ ResultSet rs = query.executeQuery();
+ assertTrue(rs.next());
+ assertEquals("happy", rs.getObject("m"));
+
// all good
+ rs.close();
query.close();
}
@@ -120,13 +124,19 @@ public class StringTypeParameterTest extends TestCase {
PreparedStatement query = _conn.prepareStatement("select * from stringtypetest where m = ?");
query.setString(1, "happy");
- query.executeQuery().close();
+ ResultSet rs = query.executeQuery();
+ assertTrue(rs.next());
+ assertEquals("happy", rs.getObject("m"));
+ rs.close();
query.clearParameters();
query.setObject(1, "happy", Types.VARCHAR);
- query.executeQuery().close();
+ rs = query.executeQuery();
+ assertTrue(rs.next());
+ assertEquals("happy", rs.getObject("m"));
// all good
+ rs.close();
query.close();
}
--
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