0

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 Answers1

0

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

Methkal Khalawi
  • 2,368
  • 1
  • 8
  • 13
  • Sorry but, in my old application I am using these kinds of filters over the google datastore. You have the com.google.appengine library which has the com.google.appengine.api.datastore.Query.CompositeFilterOperator.or and the com.google.appengine.api.datastore.Query.FilterOperator.IN to access directly from your application using this type of filters. The problem is that I am changing the infraestructure and it seems, the new one is worst technically that the old one or more limited. – Jorge Merino Llamera Dec 23 '20 at 17:06