List:Commits« Previous MessageNext Message »
From:mmatthews Date:December 19 2005 4:48pm
Subject:Connector/J commit: r4710 - in branches/branch_5_0/connector-j: . src/com/mysql/jdbc src/testsuite/regression
View as plain text  
Modified:
   branches/branch_5_0/connector-j/CHANGES
   branches/branch_5_0/connector-j/src/com/mysql/jdbc/PreparedStatement.java
   branches/branch_5_0/connector-j/src/testsuite/regression/StatementRegressionTest.java
Log:
 Fixed BUG#15383 - PreparedStatement.setObject() serializes 
      BigInteger as object, rather than sending as numeric value 
      (and is thus not complementary to .getObject() on an UNSIGNED 
      LONG type), merged from 3.1 branch.

Modified: branches/branch_5_0/connector-j/CHANGES
===================================================================
--- branches/branch_5_0/connector-j/CHANGES	2005-12-19 16:47:38 UTC (rev 4709)
+++ branches/branch_5_0/connector-j/CHANGES	2005-12-19 16:48:18 UTC (rev 4710)
@@ -96,6 +96,11 @@
             
     - Fixed BUG#15544, no "dos" character set in MySQL > 4.1.0
     
+    - Fixed BUG#15383 - PreparedStatement.setObject() serializes 
+      BigInteger as object, rather than sending as numeric value 
+      (and is thus not complementary to .getObject() on an UNSIGNED 
+      LONG type).
+      
 11-30-05 - Version 3.1.12
 
 

Modified: branches/branch_5_0/connector-j/src/com/mysql/jdbc/PreparedStatement.java
===================================================================
--- branches/branch_5_0/connector-j/src/com/mysql/jdbc/PreparedStatement.java	2005-12-19 16:47:38 UTC (rev 4709)
+++ branches/branch_5_0/connector-j/src/com/mysql/jdbc/PreparedStatement.java	2005-12-19 16:48:18 UTC (rev 4710)
@@ -33,6 +33,7 @@
 import java.io.StringReader;
 import java.io.UnsupportedEncodingException;
 import java.math.BigDecimal;
+import java.math.BigInteger;
 import java.net.URL;
 import java.sql.Array;
 import java.sql.Clob;
@@ -2563,6 +2564,8 @@
 			} else if (parameterObj instanceof java.util.Date) {
 				setTimestamp(parameterIndex, new Timestamp(
 						((java.util.Date) parameterObj).getTime()));
+			} else if (parameterObj instanceof BigInteger) {
+				setString(parameterIndex, parameterObj.toString());
 			} else {
 				setSerializableObject(parameterIndex, parameterObj);
 			}

Modified: branches/branch_5_0/connector-j/src/testsuite/regression/StatementRegressionTest.java
===================================================================
--- branches/branch_5_0/connector-j/src/testsuite/regression/StatementRegressionTest.java	2005-12-19 16:47:38 UTC (rev 4709)
+++ branches/branch_5_0/connector-j/src/testsuite/regression/StatementRegressionTest.java	2005-12-19 16:48:18 UTC (rev 4710)
@@ -35,6 +35,7 @@
 import java.io.StringReader;
 import java.io.Writer;
 import java.math.BigDecimal;
+import java.math.BigInteger;
 import java.sql.BatchUpdateException;
 import java.sql.Blob;
 import java.sql.Clob;
@@ -710,6 +711,50 @@
 		}
 	}
 	
+	/**
+	 * Tests fix for BUG#15383 - PreparedStatement.setObject()
+	 * serializes BigInteger as object, rather than sending as
+	 * numeric value (and is thus not complementary to .getObject()
+	 * on an UNSIGNED LONG type).
+	 * 
+	 * @throws Exception if the test fails.
+	 */
+	public void testBug15383() throws Exception {
+		createTable("testBug15383", "(id INTEGER UNSIGNED NOT NULL "
+				+ "AUTO_INCREMENT,value BIGINT UNSIGNED NULL DEFAULT 0,PRIMARY "
+				+ "KEY(id))ENGINE=InnoDB;");
+						
+		this.stmt.executeUpdate("INSERT INTO testBug15383(value) VALUES(1)");
+		
+		Statement updatableStmt = this.conn.createStatement(
+				ResultSet.TYPE_FORWARD_ONLY,
+				ResultSet.CONCUR_UPDATABLE);
+		
+		try {
+			this.rs = updatableStmt.executeQuery("SELECT * from testBug15383");
+			
+			assertTrue(rs.next());
+	
+			Object bigIntObj = rs.getObject("value");
+			assertEquals("java.math.BigInteger", bigIntObj.getClass().getName());
+			
+			this.rs.updateObject("value", new BigInteger("3"));
+			this.rs.updateRow();
+			
+			assertEquals("3", this.rs.getString("value"));
+		} finally {
+			if (this.rs != null) {
+				ResultSet toClose = this.rs;
+				this.rs = null;
+				toClose.close();
+			}
+			
+			if (updatableStmt != null) {
+				updatableStmt.close();
+			}
+		}		
+	}
+	
 	private void testStreamsForBug15024(boolean shouldBeClosedStream, 
 			boolean shouldBeClosedReader) throws SQLException {
 		IsClosedInputStream bIn = new IsClosedInputStream(new byte[4]);

Thread
Connector/J commit: r4710 - in branches/branch_5_0/connector-j: . src/com/mysql/jdbc src/testsuite/regressionmmatthews19 Dec