This is an automated email from the git hooks/post-receive script. ebourg-guest pushed a commit to tag REL8_0_319 in repository libpostgresql-jdbc-java.
commit 14c0041f3b355b4cd47da4cc0db430f4d2f03ae9 Author: Kris Jurka <[email protected]> Date: Mon Apr 16 16:37:04 2007 +0000 Allow updatable ResultSets to update arrays. While we still haven't implemented updateArray, updateObject with an Array should work. Just need to add a mapping for Types.ARRAY for converting the Array to the underlying ResultSet format. As reported by vasylenko. --- org/postgresql/jdbc2/AbstractJdbc2ResultSet.java | 3 +- .../test/jdbc2/UpdateableResultTest.java | 35 ++++++++++++++++++++-- 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/org/postgresql/jdbc2/AbstractJdbc2ResultSet.java b/org/postgresql/jdbc2/AbstractJdbc2ResultSet.java index d9bf7a0..2ba74d7 100644 --- a/org/postgresql/jdbc2/AbstractJdbc2ResultSet.java +++ b/org/postgresql/jdbc2/AbstractJdbc2ResultSet.java @@ -3,7 +3,7 @@ * Copyright (c) 2003-2005, PostgreSQL Global Development Group * * IDENTIFICATION -* $PostgreSQL: pgjdbc/org/postgresql/jdbc2/AbstractJdbc2ResultSet.java,v 1.71.2.7 2005/12/04 21:41:35 jurka Exp $ +* $PostgreSQL: pgjdbc/org/postgresql/jdbc2/AbstractJdbc2ResultSet.java,v 1.71.2.8 2006/08/06 18:11:52 jurka Exp $ * *------------------------------------------------------------------------- */ @@ -1721,6 +1721,7 @@ public abstract class AbstractJdbc2ResultSet implements BaseResultSet, org.postg case Types.NUMERIC: case Types.REAL: case Types.TINYINT: + case Types.ARRAY: case Types.OTHER: rowBuffer[columnIndex] = connection.encodeString(String.valueOf( valueObject)); break; diff --git a/org/postgresql/test/jdbc2/UpdateableResultTest.java b/org/postgresql/test/jdbc2/UpdateableResultTest.java index 51912e6..33d18a4 100644 --- a/org/postgresql/test/jdbc2/UpdateableResultTest.java +++ b/org/postgresql/test/jdbc2/UpdateableResultTest.java @@ -3,7 +3,7 @@ * Copyright (c) 2001-2005, PostgreSQL Global Development Group * * IDENTIFICATION -* $PostgreSQL: pgjdbc/org/postgresql/test/jdbc2/UpdateableResultTest.java,v 1.19.2.2 2005/09/29 22:12:16 jurka Exp $ +* $PostgreSQL: pgjdbc/org/postgresql/test/jdbc2/UpdateableResultTest.java,v 1.19.2.3 2007/01/05 00:34:28 jurka Exp $ * *------------------------------------------------------------------------- */ @@ -33,7 +33,7 @@ public class UpdateableResultTest extends TestCase protected void setUp() throws Exception { con = TestUtil.openDB(); - TestUtil.createTable(con, "updateable", "id int primary key, name text, notselected text, ts timestamp with time zone", true); + TestUtil.createTable(con, "updateable", "id int primary key, name text, notselected text, ts timestamp with time zone, intarr int[]", true); TestUtil.createTable(con, "second", "id1 int primary key, name1 text"); TestUtil.createTable(con, "stream", "id int primary key, asi text, chr text, bin bytea"); @@ -440,4 +440,35 @@ public class UpdateableResultTest extends TestCase fail("Should have thrown an exception on bad column index."); } catch (SQLException sqle) { } } + + public void testArray() throws SQLException { + Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE); + stmt.executeUpdate("INSERT INTO updateable (id, intarr) VALUES (1, '{1,2,3}'::int4[])"); + ResultSet rs = stmt.executeQuery("SELECT id, intarr FROM updateable"); + assertTrue(rs.next()); + rs.updateObject(2, rs.getArray(2)); + rs.updateRow(); + + Array arr = rs.getArray(2); + assertEquals(Types.INTEGER, arr.getBaseType()); + int intarr[] = (int[])arr.getArray(); + assertEquals(3, intarr.length); + assertEquals(1, intarr[0]); + assertEquals(2, intarr[1]); + assertEquals(3, intarr[2]); + rs.close(); + + rs = stmt.executeQuery("SELECT id,intarr FROM updateable"); + assertTrue(rs.next()); + arr = rs.getArray(2); + assertEquals(Types.INTEGER, arr.getBaseType()); + intarr = (int[])arr.getArray(); + assertEquals(3, intarr.length); + assertEquals(1, intarr[0]); + assertEquals(2, intarr[1]); + assertEquals(3, intarr[2]); + + rs.close(); + stmt.close(); + } } -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/libpostgresql-jdbc-java.git _______________________________________________ pkg-java-commits mailing list [email protected] http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-java-commits

