fixed issue with from clause

This commit is contained in:
Timo Westkämper 2008-03-12 22:36:31 +00:00
parent 4c856c50c0
commit 01c327e73a
2 changed files with 13 additions and 8 deletions

View File

@ -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()));
}
}

View File

@ -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();
}