Spring Boot + gcp datastore + datastore emulator gets INVALID_ARGUMENT Encountered "OR" / "IN"

325 views Asked by At

I have an application running in the App Engine Standar Environment using the Google Cloud Tools and the Datanucleus framework to access the data.

When I run this application in the local environment it works fine and, when I make a Select with an OR or an IN in the Where clause, it returns the registers of the tables without problem.

Now, I want to improve my application and create a new one using Spring Boot, the Spring Cloud GCP and the local Cloud Datastore Emulator. When I try to do a query over the Datastore Emulator it works fine but, but when the query has an IN or an OR, the emulator logs and error.

The query is:

@Query(value = "SELECT * FROM  Evento WHERE fincaId = @id_finca AND tipoEvento = 3 OR tipoEvento = 4")

And the error text:

[datastore] INFORMACI?N: Exception when handling request: INVALID_ARGUMENT: Encountered "OR" at line 1, column 68.
[datastore] Was expecting one of:
[datastore]     <EOF>
[datastore]     "and" ...
[datastore]     "group" ...
[datastore]     "limit" ...
[datastore]     "offset" ...
[datastore]     "order" ...

Can Datastore Emulator make queries with an OR or an IN clause?

Is there a way to do this in a different way?

1

There are 1 answers

1
Methkal Khalawi On

Datastore doesn't support "IN" and "OR" operators. If you want to have such a functionality, you should issues two queries and combine them client side. for full supported types and samples of queries, check this docs