mirror of
https://github.com/querydsl/querydsl.git
synced 2026-06-13 21:01:01 +08:00
Improve path in collection handling
This commit is contained in:
parent
907d97fb50
commit
e83c592d06
@ -745,7 +745,7 @@ public class SQLSerializer extends SerializerBase<SQLSerializer> {
|
||||
append(")");
|
||||
|
||||
int size = ((Collection) constant).size() - 1;
|
||||
Path<?> lastPath = constantPaths.get(constantPaths.size() - 1);
|
||||
Path<?> lastPath = constantPaths.isEmpty() ? null : constantPaths.get(constantPaths.size() - 1);
|
||||
for (int i = 0; i < size; i++) {
|
||||
constantPaths.add(lastPath);
|
||||
}
|
||||
@ -832,10 +832,13 @@ public class SQLSerializer extends SerializerBase<SQLSerializer> {
|
||||
&& args.get(0) instanceof Path<?>
|
||||
&& args.get(1) instanceof Constant<?>
|
||||
&& operator != Ops.NUMCAST) {
|
||||
for (Element element : templates.getTemplate(operator).getElements()) {
|
||||
if (element instanceof Template.ByIndex && ((Template.ByIndex)element).getIndex() == 1) {
|
||||
constantPaths.add((Path<?>)args.get(0));
|
||||
break;
|
||||
Object constant = ((Constant)args.get(1)).getConstant();
|
||||
if (!Collection.class.isInstance(constant) || !((Collection)constant).isEmpty()) {
|
||||
for (Element element : templates.getTemplate(operator).getElements()) {
|
||||
if (element instanceof Template.ByIndex && ((Template.ByIndex)element).getIndex() == 1) {
|
||||
constantPaths.add((Path<?>)args.get(0));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -594,6 +594,12 @@ public class SelectBase extends AbstractBaseTest {
|
||||
query().from(employee).where(employee.id.in(Arrays.asList(1,2))).list(employee);
|
||||
}
|
||||
|
||||
@Test
|
||||
@IncludeIn(H2)
|
||||
public void In_Empty() {
|
||||
query().from(employee).where(employee.id.in(ImmutableList.<Integer>of())).list(employee);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void Inner_Join() throws SQLException {
|
||||
query().from(employee).innerJoin(employee2)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user