MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:mmatthews Date:April 3 2006 8:06pm
Subject:Connector/J commit: r5128 - in branches: branch_3_1/connector-j branch_3_1/connector-j/src/com/mysql/jdbc branch_3_1/connector-j/src/testsuite/regress...
View as plain text  
Modified:
   branches/branch_3_1/connector-j/CHANGES
   branches/branch_3_1/connector-j/src/com/mysql/jdbc/ResultSet.java
   branches/branch_3_1/connector-j/src/testsuite/regression/ResultSetRegressionTest.java
   branches/branch_5_0/connector-j/CHANGES
   branches/branch_5_0/connector-j/src/com/mysql/jdbc/ResultSet.java
   branches/branch_5_0/connector-j/src/testsuite/regression/ResultSetRegressionTest.java
   branches/branch_5_1/connector-j/CHANGES
   branches/branch_5_1/connector-j/src/com/mysql/jdbc/ResultSet.java
   branches/branch_5_1/connector-j/src/testsuite/regression/ResultSetRegressionTest.java
Log:
Fixed BUG#17450 - ResultSet.wasNull() not always reset  correctly for booleans when done via conversion for server-side prepared statements.

Modified: branches/branch_3_1/connector-j/CHANGES
===================================================================
--- branches/branch_3_1/connector-j/CHANGES	2006-04-03 19:43:33 UTC (rev 5127)
+++ branches/branch_3_1/connector-j/CHANGES	2006-04-03 20:05:55 UTC (rev 5128)
@@ -89,6 +89,10 @@
 	  
 	- Fixed BUG#18554 - Aliased column names where length of name > 251 
 	  are corrupted.
+	  
+	- Fixed BUG#17450 - ResultSet.wasNull() not always reset
+	  correctly for booleans when done via conversion for server-side
+	  prepared statements.
 	
 11-30-05 - Version 3.1.12
 

Modified: branches/branch_3_1/connector-j/src/com/mysql/jdbc/ResultSet.java
===================================================================
--- branches/branch_3_1/connector-j/src/com/mysql/jdbc/ResultSet.java	2006-04-03 19:43:33 UTC (rev 5127)
+++ branches/branch_3_1/connector-j/src/com/mysql/jdbc/ResultSet.java	2006-04-03 20:05:55 UTC (rev 5128)
@@ -2918,6 +2918,8 @@
 
 		}
 
+		this.wasNullFlag = false;
+		
 		switch (field.getSQLType()) {
 		case Types.BIT:
 		case Types.BOOLEAN:

Modified: branches/branch_3_1/connector-j/src/testsuite/regression/ResultSetRegressionTest.java
===================================================================
--- branches/branch_3_1/connector-j/src/testsuite/regression/ResultSetRegressionTest.java	2006-04-03 19:43:33 UTC (rev 5127)
+++ branches/branch_3_1/connector-j/src/testsuite/regression/ResultSetRegressionTest.java	2006-04-03 20:05:55 UTC (rev 5128)
@@ -1391,9 +1391,9 @@
 				cal.setTimeInMillis(asMillis);
 			}
 			
-			assertTrue(cal.get(Calendar.HOUR) == 9);
-			assertTrue(cal.get(Calendar.MINUTE) == 16);
-			assertTrue(cal.get(Calendar.SECOND) == 0);
+			assertEquals(9, cal.get(Calendar.HOUR));
+			assertEquals(16, cal.get(Calendar.MINUTE));
+			assertEquals(0, cal.get(Calendar.SECOND));
 		} finally {
 			this.stmt.executeUpdate("DROP TABLE IF EXISTS testBug6231");
 		}
@@ -2280,6 +2280,44 @@
 		}
 	}
 	
+	/**
+	 * Tests fix for BUG#17450 - ResultSet.wasNull() not always reset
+	 * correctly for booleans when done via conversion for server-side
+	 * prepared statements.
+	 * 
+	 * @throws Exception if the test fails.
+	 */
+	public void testBug17450() throws Exception {
+		createTable("testBug17450", "(FOO VARCHAR(100), BAR CHAR NOT NULL)");
+
+		this.stmt.execute("insert into testBug17450 (foo,bar) values ('foo',true)");
+		this.stmt.execute("insert into testBug17450 (foo,bar) values (null,true)");
+
+		this.pstmt = this.conn.prepareStatement("select * from testBug17450 where foo=?");
+		this.pstmt.setString(1,"foo");
+		this.rs = this.pstmt.executeQuery();
+		testResult17450();
+
+		this.pstmt = this.conn.prepareStatement("select * from testBug17450 where foo is null");
+		this.rs = this.pstmt.executeQuery();
+		testResult17450();
+
+		this.rs = this.stmt.executeQuery("select * from testBug17450 where foo='foo'");
+		testResult17450();
+
+		this.rs = this.stmt.executeQuery("select * from testBug17450 where foo is null");
+		testResult17450();
+	}
+
+	private void testResult17450() throws Exception {
+		this.rs.next();
+		this.rs.getString(1);
+		boolean bar = this.rs.getBoolean(2);
+
+		assertEquals("field 2 should be true", true, bar);
+		assertFalse("wasNull should return false", this.rs.wasNull());
+	}
+
 	private void traverseResultSetBug14562() throws SQLException {
 		assertTrue(this.rs.next());
 		

Modified: branches/branch_5_0/connector-j/CHANGES
===================================================================
--- branches/branch_5_0/connector-j/CHANGES	2006-04-03 19:43:33 UTC (rev 5127)
+++ branches/branch_5_0/connector-j/CHANGES	2006-04-03 20:05:55 UTC (rev 5128)
@@ -192,6 +192,10 @@
 	  
 	- Fixed BUG#18554 - Aliased column names where length of name > 251 
 	  are corrupted.
+	  	  
+	- Fixed BUG#17450 - ResultSet.wasNull() not always reset
+	  correctly for booleans when done via conversion for server-side
+	  prepared statements.
 	
 11-30-05 - Version 3.1.12
 

Modified: branches/branch_5_0/connector-j/src/com/mysql/jdbc/ResultSet.java
===================================================================
--- branches/branch_5_0/connector-j/src/com/mysql/jdbc/ResultSet.java	2006-04-03 19:43:33 UTC (rev 5127)
+++ branches/branch_5_0/connector-j/src/com/mysql/jdbc/ResultSet.java	2006-04-03 20:05:55 UTC (rev 5128)
@@ -2960,6 +2960,8 @@
 
 		}
 
+		this.wasNullFlag = false;
+		
 		switch (field.getSQLType()) {
 		case Types.BIT:
 		case Types.BOOLEAN:

Modified: branches/branch_5_0/connector-j/src/testsuite/regression/ResultSetRegressionTest.java
===================================================================
--- branches/branch_5_0/connector-j/src/testsuite/regression/ResultSetRegressionTest.java	2006-04-03 19:43:33 UTC (rev 5127)
+++ branches/branch_5_0/connector-j/src/testsuite/regression/ResultSetRegressionTest.java	2006-04-03 20:05:55 UTC (rev 5128)
@@ -2929,4 +2929,43 @@
 			}
 		}
 	}
+	
+	/**
+	 * Tests fix for BUG#17450 - ResultSet.wasNull() not always reset
+	 * correctly for booleans when done via conversion for server-side
+	 * prepared statements.
+	 * 
+	 * @throws Exception if the test fails.
+	 */
+	public void testBug17450() throws Exception {
+		createTable("testBug17450", "(FOO VARCHAR(100), BAR CHAR NOT NULL)");
+
+		this.stmt.execute("insert into testBug17450 (foo,bar) values ('foo',true)");
+		this.stmt.execute("insert into testBug17450 (foo,bar) values (null,true)");
+
+		this.pstmt = this.conn.prepareStatement("select * from testBug17450 where foo=?");
+		this.pstmt.setString(1,"foo");
+		this.rs = this.pstmt.executeQuery();
+		testResult17450();
+
+		this.pstmt = this.conn.prepareStatement("select * from testBug17450 where foo is null");
+		this.rs = this.pstmt.executeQuery();
+		testResult17450();
+
+		this.rs = this.stmt.executeQuery("select * from testBug17450 where foo='foo'");
+		testResult17450();
+
+		this.rs = this.stmt.executeQuery("select * from testBug17450 where foo is null");
+		testResult17450();
+	}
+
+	private void testResult17450() throws Exception {
+		this.rs.next();
+		this.rs.getString(1);
+		boolean bar = this.rs.getBoolean(2);
+
+		assertEquals("field 2 should be true", true, bar);
+		assertFalse("wasNull should return false", this.rs.wasNull());
+	}
+
 }

Modified: branches/branch_5_1/connector-j/CHANGES
===================================================================
--- branches/branch_5_1/connector-j/CHANGES	2006-04-03 19:43:33 UTC (rev 5127)
+++ branches/branch_5_1/connector-j/CHANGES	2006-04-03 20:05:55 UTC (rev 5128)
@@ -194,6 +194,10 @@
 	  
 	- Fixed BUG#18554 - Aliased column names where length of name > 251 
 	  are corrupted.
+	  
+	- Fixed BUG#17450 - ResultSet.wasNull() not always reset
+	  correctly for booleans when done via conversion for server-side
+	  prepared statements.
 	
 11-30-05 - Version 3.1.12
 

Modified: branches/branch_5_1/connector-j/src/com/mysql/jdbc/ResultSet.java
===================================================================
--- branches/branch_5_1/connector-j/src/com/mysql/jdbc/ResultSet.java	2006-04-03 19:43:33 UTC (rev 5127)
+++ branches/branch_5_1/connector-j/src/com/mysql/jdbc/ResultSet.java	2006-04-03 20:05:55 UTC (rev 5128)
@@ -2998,6 +2998,8 @@
 
 		}
 
+		this.wasNullFlag = false;
+		
 		switch (field.getSQLType()) {
 		case Types.BIT:
 		case Types.BOOLEAN:

Modified: branches/branch_5_1/connector-j/src/testsuite/regression/ResultSetRegressionTest.java
===================================================================
--- branches/branch_5_1/connector-j/src/testsuite/regression/ResultSetRegressionTest.java	2006-04-03 19:43:33 UTC (rev 5127)
+++ branches/branch_5_1/connector-j/src/testsuite/regression/ResultSetRegressionTest.java	2006-04-03 20:05:55 UTC (rev 5128)
@@ -2929,4 +2929,43 @@
 			}
 		}
 	}
+	
+	/**
+	 * Tests fix for BUG#17450 - ResultSet.wasNull() not always reset
+	 * correctly for booleans when done via conversion for server-side
+	 * prepared statements.
+	 * 
+	 * @throws Exception if the test fails.
+	 */
+	public void testBug17450() throws Exception {
+		createTable("testBug17450", "(FOO VARCHAR(100), BAR CHAR NOT NULL)");
+
+		this.stmt.execute("insert into testBug17450 (foo,bar) values ('foo',true)");
+		this.stmt.execute("insert into testBug17450 (foo,bar) values (null,true)");
+
+		this.pstmt = this.conn.prepareStatement("select * from testBug17450 where foo=?");
+		this.pstmt.setString(1,"foo");
+		this.rs = this.pstmt.executeQuery();
+		testResult17450();
+
+		this.pstmt = this.conn.prepareStatement("select * from testBug17450 where foo is null");
+		this.rs = this.pstmt.executeQuery();
+		testResult17450();
+
+		this.rs = this.stmt.executeQuery("select * from testBug17450 where foo='foo'");
+		testResult17450();
+
+		this.rs = this.stmt.executeQuery("select * from testBug17450 where foo is null");
+		testResult17450();
+	}
+
+	private void testResult17450() throws Exception {
+		this.rs.next();
+		this.rs.getString(1);
+		boolean bar = this.rs.getBoolean(2);
+
+		assertEquals("field 2 should be true", true, bar);
+		assertFalse("wasNull should return false", this.rs.wasNull());
+	}
+
 }

Thread
Connector/J commit: r5128 - in branches: branch_3_1/connector-j branch_3_1/connector-j/src/com/mysql/jdbc branch_3_1/connector-j/src/testsuite/regress...mmatthews3 Apr