Improve null handling

This commit is contained in:
Timo Westkämper 2016-04-05 22:06:39 +03:00
parent 5cdb0e3112
commit a6d14a2602
2 changed files with 8 additions and 2 deletions

View File

@ -107,7 +107,7 @@ public final class Configuration {
*/
@SuppressWarnings("unchecked")
public String asLiteral(Object o) {
if (Null.class.isInstance(o)) {
if (o == null || o instanceof Null) {
return "null";
} else {
Type type = javaTypeMapping.getType(o.getClass());
@ -222,7 +222,7 @@ public final class Configuration {
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
public <T> void set(PreparedStatement stmt, Path<?> path, int i, T value) throws SQLException {
if (Null.class.isInstance(value)) {
if (value == null || value instanceof Null) {
Integer sqlType = null;
if (path != null) {
ColumnMetadata columnMetadata = ColumnMetadata.getColumnMetadata(path);

View File

@ -895,6 +895,12 @@ public class SelectBase extends AbstractBaseTest {
assertEquals(0, query().from(employee).where(employee.id.in(ImmutableList.<Integer>of())).fetchCount());
}
@Test
@ExcludeIn(DERBY)
public void in_null() {
assertEquals(1, query().from(employee).where(employee.id.in(1, null)).fetchCount());
}
@Test
@ExcludeIn({MYSQL, TERADATA})
public void in_subqueries() {