AppEngine: query data store for columns with a hyphen in its name

I am working on a servlet in Google App Engine. This servlet retrieves data from the GAE data store; everything works fine when querying like "SELECT * FROM ...". But when I want to filter it by a specific column, it does not work, because the column name has hypen. This is similar to the following:

Query query = new Query("tableName"); query.addFilter("col-name", Query.FilterOperator.EQUAL, filterValue); 

How to pass property Name with hyphen?

+4
source share
3 answers

There are no rows or columns in the AppEngine data store; It has models and properties.

Defining data classes talks about defining your models; it is important to note that Java rules for identifier names matter, because each property of the model will at some point be turned into a Java object with the same name.

You yourself described it:

if I filter a column called "field-1", I kind of tried to subtract 1 from every returned value of a column called field

+2
source

java accepts only the letters and numbers of the dollar sign "$", or the underscore character "_", as legal identifiers. Therefore, I believe that this is impossible. Also did not work in python

http://java.sun.com/docs/books/tutorial/java/nutsandbolts/variables.html#naming

+1
source

Is the addFilter method the correct single-quoted column name application? You might want to add them yourself. You can filter things that are not keys in the database in GQL, so this may be something that is expected of you.

0
source

All Articles