mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
EQL - parsing fetch clause
This commit is contained in:
@@ -88,6 +88,28 @@ class EqlAdapter<T> extends EQLBaseListener {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enterFetch_path(EQLParser.Fetch_pathContext ctx) {
|
||||
int childCount = ctx.getChildCount();
|
||||
checkChildren(ctx, 2);
|
||||
String path = child(ctx, 1);
|
||||
if (childCount == 2) {
|
||||
query.fetch(path);
|
||||
|
||||
} else {
|
||||
String fetchProperties = trimParenthesis(ctx.getChild(2).getText());
|
||||
query.fetch(path, fetchProperties);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Trim leading '(' and trailing ')'
|
||||
*/
|
||||
private String trimParenthesis(String text) {
|
||||
text = text.substring(1);
|
||||
text = text.substring(0, text.length()-1);
|
||||
return text;
|
||||
}
|
||||
|
||||
private String getLeftHandSidePath(ParserRuleContext ctx) {
|
||||
TerminalNode pathToken = ctx.getToken(EQLLexer.PATH_VARIABLE, 0);
|
||||
@@ -128,7 +150,7 @@ class EqlAdapter<T> extends EQLBaseListener {
|
||||
int childCount = ctx.getChildCount();
|
||||
for (int i = 0; i < childCount; i++) {
|
||||
String text = child(ctx, i);
|
||||
if (isInValue(text)) {
|
||||
if (isValue(text)) {
|
||||
inValues.add(helper.bind(text));
|
||||
}
|
||||
}
|
||||
@@ -139,7 +161,7 @@ class EqlAdapter<T> extends EQLBaseListener {
|
||||
return child.getText();
|
||||
}
|
||||
|
||||
private boolean isInValue(String text) {
|
||||
private boolean isValue(String text) {
|
||||
if (text.length() == 1 && (text.equals("(") || text.equals(")") || text.equals(","))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -71,6 +71,18 @@ public class EQLBaseListener implements EQLListener {
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitFetch_path(EQLParser.Fetch_pathContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterFetch_property_set(EQLParser.Fetch_property_setContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitFetch_property_set(EQLParser.Fetch_property_setContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
|
||||
@@ -57,6 +57,16 @@ public interface EQLListener extends ParseTreeListener {
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitFetch_path(EQLParser.Fetch_pathContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link EQLParser#fetch_property_set}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterFetch_property_set(EQLParser.Fetch_property_setContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link EQLParser#fetch_property_set}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitFetch_property_set(EQLParser.Fetch_property_setContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link EQLParser#fetch_property_group}.
|
||||
* @param ctx the parse tree
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user