mirror of
https://github.com/querydsl/querydsl.git
synced 2026-06-16 21:01:10 +08:00
Merge branch 'null-expression' of git://github.com/Danepic/querydsl into Danepic-null-expression
This commit is contained in:
commit
c038ffcded
@ -33,7 +33,7 @@ public final class NullExpression<T> extends TemplateExpressionImpl<T> {
|
||||
*/
|
||||
public static final NullExpression<Object> DEFAULT = new NullExpression<Object>(Object.class);
|
||||
|
||||
private NullExpression(Class<? extends T> type) {
|
||||
public NullExpression(Class<? extends T> type) {
|
||||
super(type, NULL_TEMPLATE, ImmutableList.of());
|
||||
}
|
||||
|
||||
|
||||
@ -15,11 +15,30 @@
|
||||
package com.querydsl.core.types.dsl;
|
||||
|
||||
import java.sql.Time;
|
||||
import java.util.*;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.querydsl.core.Tuple;
|
||||
import com.querydsl.core.types.*;
|
||||
import com.querydsl.core.types.CollectionExpression;
|
||||
import com.querydsl.core.types.ConstantImpl;
|
||||
import com.querydsl.core.types.Expression;
|
||||
import com.querydsl.core.types.ExpressionUtils;
|
||||
import com.querydsl.core.types.NullExpression;
|
||||
import com.querydsl.core.types.OperationImpl;
|
||||
import com.querydsl.core.types.Operator;
|
||||
import com.querydsl.core.types.Ops;
|
||||
import com.querydsl.core.types.Path;
|
||||
import com.querydsl.core.types.PathImpl;
|
||||
import com.querydsl.core.types.PathMetadata;
|
||||
import com.querydsl.core.types.PathMetadataFactory;
|
||||
import com.querydsl.core.types.PredicateOperation;
|
||||
import com.querydsl.core.types.PredicateTemplate;
|
||||
import com.querydsl.core.types.Template;
|
||||
import com.querydsl.core.types.TemplateExpressionImpl;
|
||||
import com.querydsl.core.types.TemplateFactory;
|
||||
import com.querydsl.core.types.Visitor;
|
||||
|
||||
/**
|
||||
* Factory class for {@link Expression} creation.
|
||||
@ -1670,7 +1689,7 @@ public final class Expressions {
|
||||
* @return null expression
|
||||
*/
|
||||
public static <T> NullExpression<T> nullExpression(Class<T> type) {
|
||||
return nullExpression();
|
||||
return new NullExpression<T>(type);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright 2015, The Querydsl Team (http://www.querydsl.com/team)
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.querydsl.core;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.querydsl.core.domain.Cat;
|
||||
import com.querydsl.core.domain.QCat;
|
||||
import com.querydsl.core.types.ExpressionException;
|
||||
import com.querydsl.core.types.Projections;
|
||||
import com.querydsl.core.types.dsl.Expressions;
|
||||
|
||||
public class NullExpressionTest {
|
||||
|
||||
@Test
|
||||
public void withConstructor() {
|
||||
Cat cat = Projections.constructor(Cat.class, Expressions.nullExpression(String.class), QCat.cat.id, QCat.cat.bodyWeight).newInstance(null, 1, 2.5);
|
||||
assertNotNull(cat);
|
||||
}
|
||||
|
||||
|
||||
@Test(expected = ExpressionException.class)
|
||||
public void withoutConstructor() {
|
||||
Cat cat = Projections.constructor(Cat.class, Expressions.nullExpression(String.class), QCat.cat.id, QCat.cat.birthdate).newInstance(null, 1, LocalDate.now());
|
||||
assertNotNull(cat);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user