Skip to content

Commit

Permalink
Improve null handling
Browse files Browse the repository at this point in the history
  • Loading branch information
timowest committed Apr 6, 2016
1 parent 5cdb0e3 commit a6d14a2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Expand Up @@ -107,7 +107,7 @@ public Configuration(SQLTemplates templates) {
*/
@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());
Expand Down Expand Up @@ -222,7 +222,7 @@ public String getColumnOverride(SchemaAndTable key, String column) {
*/
@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);
Expand Down
6 changes: 6 additions & 0 deletions querydsl-sql/src/test/java/com/querydsl/sql/SelectBase.java
Expand Up @@ -895,6 +895,12 @@ public void in_empty() {
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() {
Expand Down

0 comments on commit a6d14a2

Please sign in to comment.