@@ -2260,6 +2260,7 @@ public void testLoadData() throws Exception {
22602260 assertThrows (SQLException .class ,
22612261 versionMeetsMinimum (8 , 0 , 19 ) ? "Loading local data is disabled;.*" : "The used command is not allowed with this MySQL version" ,
22622262 new Callable <Void >() {
2263+ @ SuppressWarnings ("synthetic-access" )
22632264 public Void call () throws Exception {
22642265 StatementRegressionTest .this .stmt
22652266 .executeUpdate ("LOAD DATA LOCAL INFILE '" + fileName + "' INTO TABLE loadDataRegress CHARACTER SET "
@@ -8858,4 +8859,60 @@ public void testBug96442() throws Exception {
88588859
88598860 }
88608861
8862+ /**
8863+ * Tests fix for Bug#98237 (30911870), PREPAREDSTATEMENT.SETOBJECT(I, "FALSE", TYPES.BOOLEAN) ALWAYS SETS TRUE OR 1.
8864+ */
8865+ public void testBug98237 () throws Exception {
8866+ createTable ("testBug98237" , "(b tinyint)" );
8867+
8868+ String [] falses = new String [] { "False" , "n" , "0" , "-0" , "0.00" , "-0.0" };
8869+ String [] trues = new String [] { "true" , "y" , "1" , "-1" , "1.0" , "-1.0" , "0.01" , "-0.01" };
8870+
8871+ Properties props = new Properties ();
8872+ boolean useSPS = false ;
8873+ do {
8874+ props .setProperty ("useServerPrepStmts" , Boolean .toString (useSPS ));
8875+ Connection con = getConnectionWithProps (props );
8876+ try {
8877+ final PreparedStatement ps = con .prepareStatement ("insert into testBug98237 values(?)" );
8878+ Statement st = con .createStatement ();
8879+
8880+ con .createStatement ().execute ("truncate table testBug98237" );
8881+ for (String val : falses ) {
8882+ ps .clearParameters ();
8883+ ps .setObject (1 , val , Types .BOOLEAN );
8884+ ps .execute ();
8885+ }
8886+ this .rs = st .executeQuery ("select * from testBug98237" );
8887+ for (String val : falses ) {
8888+ assertTrue (this .rs .next ());
8889+ assertEquals ("'false' was expected for " + val , 0 , this .rs .getInt (1 ));
8890+ }
8891+
8892+ con .createStatement ().execute ("truncate table testBug98237" );
8893+ for (String val : trues ) {
8894+ ps .clearParameters ();
8895+ ps .setObject (1 , val , Types .BOOLEAN );
8896+ ps .execute ();
8897+ }
8898+ this .rs = st .executeQuery ("select * from testBug98237" );
8899+ for (String val : trues ) {
8900+ assertTrue (this .rs .next ());
8901+ assertEquals ("'true' was expected for " + val , 1 , this .rs .getInt (1 ));
8902+ }
8903+
8904+ ps .clearParameters ();
8905+ assertThrows (SQLException .class , "No conversion from abc to Types.BOOLEAN possible." , new Callable <Void >() {
8906+ public Void call () throws Exception {
8907+ ps .setObject (1 , "abc" , Types .BOOLEAN );
8908+ return null ;
8909+ }
8910+ });
8911+
8912+ } finally {
8913+ con .close ();
8914+ }
8915+ } while (useSPS = !useSPS );
8916+
8917+ }
88618918}
0 commit comments