Skip to content

Commit 41e8df9

Browse files
Merge pull request #148 from oracle/boolean-type
Tests for BOOLEAN
2 parents 17adf49 + bb26e3e commit 41e8df9

File tree

2 files changed

+65
-7
lines changed

2 files changed

+65
-7
lines changed

src/test/java/oracle/r2dbc/impl/OracleReadableMetadataImplTest.java

+25-1
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,8 @@ public void testObjectTypes() {
532532
*/
533533
@Test
534534
public void testVectorType() throws SQLException {
535-
Assumptions.assumeTrue(databaseVersion() >= 23);
535+
Assumptions.assumeTrue(databaseVersion() >= 23,
536+
"VECTOR requires Oracle Database 23ai or newer");
536537

537538
Connection connection =
538539
Mono.from(sharedConnection()).block(connectTimeout());
@@ -552,7 +553,30 @@ public void testVectorType() throws SQLException {
552553
finally {
553554
tryAwaitNone(connection.close());
554555
}
556+
}
557+
558+
/**
559+
* Verifies the implementation of {@link OracleReadableMetadataImpl} for
560+
* BOOLEAN type columns. When the test database is older than version 23ai,
561+
* this test is ignored; The BOOLEAN type was added in 23ai.
562+
*/
563+
@Test
564+
public void testBooleanType() throws SQLException {
565+
Assumptions.assumeTrue(databaseVersion() >= 23,
566+
"BOOLEAN requires Oracle Database 23ai or newer");
555567

568+
Connection connection =
569+
Mono.from(sharedConnection()).block(connectTimeout());
570+
try {
571+
// Expect BOOLEAN and Boolean to map.
572+
verifyColumnMetadata(
573+
connection, "BOOLEAN", JDBCType.BOOLEAN, R2dbcType.BOOLEAN,
574+
null, null,
575+
Boolean.class, true);
576+
}
577+
finally {
578+
tryAwaitNone(connection.close());
579+
}
556580
}
557581

558582
/**

src/test/java/oracle/r2dbc/impl/TypeMappingTest.java

+40-6
Original file line numberDiff line numberDiff line change
@@ -436,16 +436,15 @@ public void testJsonMapping() {
436436
tryAwaitNone(connection.close());
437437
}
438438
}
439-
440439
/**
441440
* <p>
442441
* Verifies the implementation of Java to SQL and SQL to Java type mappings
443442
* where the Java type is {@link Boolean} and the SQL type is a numeric type.
444-
* The R2DBC 0.9.0 Specification only requires that Java {@code Boolean} be
445-
* mapped to the SQL BOOLEAN type, however Oracle Database does not support a
446-
* BOOLEAN column type. To allow the use of the {@code Boolean} bind
447-
* values, Oracle JDBC supports binding the Boolean as a NUMBER. Oracle
448-
* R2DBC is expected to expose this functionality as well.
443+
* The R2DBC 1.0.0 Specification only requires that Java {@code Boolean} be
444+
* mapped to the SQL BOOLEAN type, however Oracle Database did not support a
445+
* BOOLEAN column type until the 23ai release. To allow the use of the
446+
* {@code Boolean} bind values, Oracle JDBC supports binding the Boolean as a
447+
* NUMBER. Oracle R2DBC is expected to expose this functionality as well.
449448
*</p>
450449
*/
451450
@Test
@@ -474,6 +473,41 @@ public void testBooleanNumericMapping() {
474473
}
475474
}
476475

476+
/**
477+
* <p>
478+
* Verifies the implementation of Java to SQL and SQL to Java type mappings
479+
* where the Java type is {@link Boolean} and the SQL type is BOOLEAN. Oracle
480+
* Database added support for a BOOLEAN column type in the 23ai release.
481+
*</p>
482+
*/
483+
@Test
484+
public void testBooleanMapping() {
485+
assumeTrue(databaseVersion() >= 23,
486+
"BOOLEAN requires Oracle Database 23ai or newer");
487+
488+
Connection connection =
489+
Mono.from(sharedConnection()).block(connectTimeout());
490+
try {
491+
// Expect BOOLEAN and Boolean to map
492+
verifyTypeMapping(connection, true, "BOOLEAN",
493+
(expected, actual) -> assertEquals(Boolean.TRUE, actual));
494+
verifyTypeMapping(connection, false, "BOOLEAN",
495+
(expected, actual) -> assertEquals(Boolean.FALSE, actual));
496+
497+
// Expect NUMBER and Boolean to map, with Row.get(..., Boolean.class)
498+
// mapping the NUMBER column value to Boolean
499+
verifyTypeMapping(connection, true, "BOOLEAN",
500+
row -> row.get(0, Boolean.class),
501+
(expected, actual) -> assertTrue(actual));
502+
verifyTypeMapping(connection, false, "BOOLEAN",
503+
row -> row.get(0, Boolean.class),
504+
(expected, actual) -> assertFalse(actual));
505+
}
506+
finally {
507+
tryAwaitNone(connection.close());
508+
}
509+
}
510+
477511
/**
478512
* <p>
479513
* Verifies the implementation of Java to SQL and SQL to Java type mappings

0 commit comments

Comments
 (0)