mirror of
https://github.com/querydsl/querydsl.git
synced 2026-06-30 21:08:30 +08:00
fixed issue with from clause
This commit is contained in:
parent
4c856c50c0
commit
01c327e73a
@ -66,7 +66,7 @@ public class HqlSerializer extends VisitorAdapter<HqlSerializer>{
|
||||
JoinExpression je = joins.get(i);
|
||||
if (i > 0){
|
||||
String sep = ", ";
|
||||
switch(je.type){
|
||||
switch(je.getType()){
|
||||
case FULLJOIN: sep = "\nfull join "; break;
|
||||
case INNERJOIN: sep = "\ninner join "; break;
|
||||
case JOIN: sep = "\njoin "; break;
|
||||
@ -75,12 +75,12 @@ public class HqlSerializer extends VisitorAdapter<HqlSerializer>{
|
||||
_append(sep);
|
||||
}
|
||||
// type specifier
|
||||
if (je.target instanceof PathEntity && !je.target.toString().contains(".")){
|
||||
_append(((PathEntity<?>)je.target).getType().getSimpleName())._append(" ");
|
||||
if (je.getTarget() instanceof PathEntity && ((Path<?>)je.getTarget()).getMetadata().getParent() == null){
|
||||
_append(((PathEntity<?>)je.getTarget()).getType().getSimpleName())._append(" ");
|
||||
}
|
||||
handle(je.target);
|
||||
if (je.conditions != null){
|
||||
_append("\nwith ")._append(" and ", Arrays.asList(je.conditions));
|
||||
handle(je.getTarget());
|
||||
if (je.getConditions() != null){
|
||||
_append("\nwith ")._append(" and ", Arrays.asList(je.getConditions()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -73,6 +73,11 @@ public class HqlParserTest extends HqlQueryBase<HqlParserTest>{
|
||||
private Domain1.Product prod = new Domain1.Product("prod");
|
||||
|
||||
private Domain1.Store store = new Domain1.Store("store");
|
||||
|
||||
private HqlParserTest expect(String string) {
|
||||
assertEquals(string, toString().replace('\n',' '));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Section 9.2 - from *
|
||||
@ -80,13 +85,13 @@ public class HqlParserTest extends HqlQueryBase<HqlParserTest>{
|
||||
@Test
|
||||
public void testDocoExamples92() throws Exception {
|
||||
// parse( "from eg.Cat" );
|
||||
from(cat).parse();
|
||||
from(cat).expect("from Cat cat").parse();
|
||||
// parse( "from eg.Cat as cat" );
|
||||
from(cat).parse();
|
||||
// parse( "from eg.Cat cat" );
|
||||
from(cat).parse();
|
||||
// parse( "from Formula, Parameter" );
|
||||
from(form, param).parse();
|
||||
from(form, param).expect("from Formula form, Parameter param").parse();
|
||||
// parse( "from Formula as form, Parameter as param" );
|
||||
from(form, param).parse();
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user