-
Notifications
You must be signed in to change notification settings - Fork 198
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add explicit handling of JDBC type for Oracle boolean type (#2852)
- Loading branch information
1 parent
7596853
commit 9544469
Showing
5 changed files
with
100 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
data-jdbc/src/test/groovy/io/micronaut/data/jdbc/oraclexe/bool/BooleanTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package io.micronaut.data.jdbc.oraclexe.bool; | ||
|
||
import io.micronaut.core.annotation.Nullable; | ||
import io.micronaut.data.annotation.GeneratedValue; | ||
import io.micronaut.data.annotation.Id; | ||
import io.micronaut.data.annotation.MappedEntity; | ||
import jakarta.persistence.Column; | ||
|
||
@MappedEntity | ||
public record BooleanTest( | ||
@Id @GeneratedValue | ||
Long id, | ||
@Column(nullable = true) | ||
@Nullable | ||
Boolean canBeNull | ||
) { | ||
} |
9 changes: 9 additions & 0 deletions
9
...dbc/src/test/groovy/io/micronaut/data/jdbc/oraclexe/bool/OracleBooleanTestRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package io.micronaut.data.jdbc.oraclexe.bool; | ||
|
||
import io.micronaut.data.jdbc.annotation.JdbcRepository; | ||
import io.micronaut.data.model.query.builder.sql.Dialect; | ||
import io.micronaut.data.repository.CrudRepository; | ||
|
||
@JdbcRepository(dialect = Dialect.ORACLE) | ||
public interface OracleBooleanTestRepository extends CrudRepository<BooleanTest, Long> { | ||
} |
43 changes: 43 additions & 0 deletions
43
...-jdbc/src/test/groovy/io/micronaut/data/jdbc/oraclexe/bool/OracleXEBooleanTypeSpec.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package io.micronaut.data.jdbc.oraclexe.bool | ||
|
||
import io.micronaut.context.ApplicationContext | ||
import io.micronaut.data.jdbc.oraclexe.OracleTestPropertyProvider | ||
import spock.lang.AutoCleanup | ||
import spock.lang.Shared | ||
import spock.lang.Specification | ||
|
||
class OracleXEBooleanTypeSpec extends Specification implements OracleTestPropertyProvider { | ||
@AutoCleanup | ||
@Shared | ||
ApplicationContext applicationContext = ApplicationContext.run(properties) | ||
|
||
void "test persist oracle boolean type as null"() { | ||
given: | ||
def repository = applicationContext.getBean(OracleBooleanTestRepository) | ||
|
||
when: | ||
def result = repository.save(new BooleanTest(null, null)) | ||
result = repository.findById(result.id()).orElse(null) | ||
|
||
then: | ||
result != null | ||
result.canBeNull() == null | ||
|
||
when: | ||
repository.update(new BooleanTest(result.id(), true)) | ||
result = repository.findById(result.id()).orElse(null) | ||
|
||
then: | ||
result != null | ||
result.canBeNull() | ||
|
||
when: | ||
repository.update(new BooleanTest(result.id(), null)) | ||
result = repository.findById(result.id()).orElse(null) | ||
|
||
then: | ||
result != null | ||
result.canBeNull() == null | ||
|
||
} | ||
} |