Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQL syntax error. #288

Open
siwee opened this issue Jul 30, 2021 · 3 comments
Open

SQL syntax error. #288

siwee opened this issue Jul 30, 2021 · 3 comments

Comments

@siwee
Copy link

siwee commented Jul 30, 2021

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.

@siwee
Copy link
Author

siwee commented Jul 30, 2021

It works fine in mysql.

@npgall
Copy link
Owner

npgall commented Jul 30, 2021

The syntax is: <attribute> LIKE <pattern>

@siwee
Copy link
Author

siwee commented Nov 28, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants