use of com.haulmont.cuba.core.sys.jpql.antlr2.JPA2Parser in project cuba by cuba-platform.
the class Jpa2GrammarTest method testEscape.
@Test
public void testEscape() throws Exception {
String query = "c.name like :pattern escape '/'";
CharStream cs = new AntlrNoCaseStringStream(query);
JPA2Lexer lexer = new JPA2Lexer(cs);
TokenStream tstream = new CommonTokenStream(lexer);
JPA2Parser jpa2Parser = new JPA2Parser(tstream);
JPA2Parser.like_expression_return aReturn = jpa2Parser.like_expression();
Assert.assertNotNull(aReturn);
query = "c.name like :pattern escape '.'";
cs = new AntlrNoCaseStringStream(query);
lexer = new JPA2Lexer(cs);
tstream = new CommonTokenStream(lexer);
jpa2Parser = new JPA2Parser(tstream);
aReturn = jpa2Parser.like_expression();
Assert.assertTrue(isValid((CommonTree) aReturn.getTree()));
}
use of com.haulmont.cuba.core.sys.jpql.antlr2.JPA2Parser in project cuba by cuba-platform.
the class Parser method parse.
public static CommonTree parse(String input, boolean failOnErrors) throws RecognitionException {
JPA2Parser parser = createParser(input);
JPA2Parser.ql_statement_return aReturn = parser.ql_statement();
CommonTree tree = (CommonTree) aReturn.getTree();
if (failOnErrors) {
checkTreeForExceptions(input, tree);
}
return tree;
}
use of com.haulmont.cuba.core.sys.jpql.antlr2.JPA2Parser in project cuba by cuba-platform.
the class Parser method parseSelectionSource.
public static CommonTree parseSelectionSource(String input) throws RecognitionException {
JPA2Parser parser = createParser(input);
JPA2Parser.identification_variable_declaration_or_collection_member_declaration_return aReturn = parser.identification_variable_declaration_or_collection_member_declaration();
CommonTree tree = (CommonTree) aReturn.getTree();
checkTreeForExceptions(input, tree);
return tree;
}
use of com.haulmont.cuba.core.sys.jpql.antlr2.JPA2Parser in project cuba by cuba-platform.
the class Jpa2GrammarTest method testUpdate.
@Test
public void testUpdate() throws Exception {
String query = "update sec$User u set u.group = :group where u.id = :userId";
CharStream cs = new AntlrNoCaseStringStream(query);
JPA2Lexer lexer = new JPA2Lexer(cs);
TokenStream tstream = new CommonTokenStream(lexer);
JPA2Parser jpa2Parser = new JPA2Parser(tstream);
JPA2Parser.update_statement_return aReturn = jpa2Parser.update_statement();
Assert.assertTrue(isValid((CommonTree) aReturn.getTree()));
}
use of com.haulmont.cuba.core.sys.jpql.antlr2.JPA2Parser in project cuba by cuba-platform.
the class Jpa2GrammarTest method testTypeField.
@Test
public void testTypeField() throws Exception {
String query = "where e.model.type = :component$filter.model_type89015";
CharStream cs = new AntlrNoCaseStringStream(query);
JPA2Lexer lexer = new JPA2Lexer(cs);
TokenStream tstream = new CommonTokenStream(lexer);
JPA2Parser jpa2Parser = new JPA2Parser(tstream);
JPA2Parser.where_clause_return aReturn = jpa2Parser.where_clause();
Assert.assertTrue(isValid((CommonTree) aReturn.getTree()));
}
Aggregations