This is an automated email from the git hooks/post-receive script. ebourg-guest pushed a commit to tag REL8_1_409 in repository libpostgresql-jdbc-java.
commit 124c2edd52c46bc2d124a5add5c5ef076d63bd05 Author: Kris Jurka <[email protected]> Date: Mon Apr 16 16:36:56 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 6d85ca5..664f241 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.80.2.2 2006/08/06 18:11:43 jurka Exp $ +* $PostgreSQL: pgjdbc/org/postgresql/jdbc2/AbstractJdbc2ResultSet.java,v 1.80.2.3 2007/02/19 06:05:01 jurka Exp $ * *------------------------------------------------------------------------- */ @@ -1710,6 +1710,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 43c199e..7be8b80 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.22 2005/09/29 22:13:25 jurka Exp $ +* $PostgreSQL: pgjdbc/org/postgresql/test/jdbc2/UpdateableResultTest.java,v 1.22.2.1 2007/01/05 00:34:20 jurka Exp $ * *------------------------------------------------------------------------- */ @@ -39,7 +39,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"); @@ -446,4 +446,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

