cqengine
cqengine copied to clipboard
SQL syntax error.
Hi. @npgall
The value of the field name is a fuzzy pattern, such as John%; I use SQL: SELECT * FROM cars WHERE 'John Nash' like name, but it throws an exception. I need your help! Thanks a lot.
Code:
SQLParser<Person> parser = SQLParser.forPojoWithAttributes(Person.class, createAttributes(Person.class));
Query<Person> query = parser.query("SELECT * FROM cars WHERE 'John Nash' like name");
doQuery(query);
Exception:
com.googlecode.cqengine.query.parser.common.InvalidQueryException: Failed to parse query at line 1:46: mismatched input '<EOF>' expecting '||'
at com.googlecode.cqengine.query.parser.common.QueryParser$1.syntaxError(QueryParser.java:54)
at org.antlr.v4.runtime.ProxyErrorListener.syntaxError(ProxyErrorListener.java:41)
at org.antlr.v4.runtime.Parser.notifyErrorListeners(Parser.java:544)
at org.antlr.v4.runtime.DefaultErrorStrategy.reportInputMismatch(DefaultErrorStrategy.java:327)
at org.antlr.v4.runtime.DefaultErrorStrategy.reportError(DefaultErrorStrategy.java:139)
at com.googlecode.cqengine.query.parser.sql.grammar.SQLGrammarParser.isPrefixOfQuery(SQLGrammarParser.java:1794)
at com.googlecode.cqengine.query.parser.sql.grammar.SQLGrammarParser.simpleQuery(SQLGrammarParser.java:943)
at com.googlecode.cqengine.query.parser.sql.grammar.SQLGrammarParser.query(SQLGrammarParser.java:467)
at com.googlecode.cqengine.query.parser.sql.grammar.SQLGrammarParser.whereClause(SQLGrammarParser.java:349)
at com.googlecode.cqengine.query.parser.sql.grammar.SQLGrammarParser.start(SQLGrammarParser.java:245)
at com.googlecode.cqengine.query.parser.sql.SQLParser.parse(SQLParser.java:62)
at com.googlecode.cqengine.query.parser.common.QueryParser.query(QueryParser.java:161)
Best Regards.
It works fine in mysql.
The syntax is: <attribute> LIKE <pattern>
The syntax is:
<attribute> LIKE <pattern>
Hi, @npgall
I don't know whether <pattern> LIKE <attribute> is supported in the standard sql syntax, but postgresql and mysql support it. This is very useful in some cases, so is it possible to provide support for this syntax in cqengine? Many thanks.
Best Regards.