开发者

AppEngine: Query datastore for columns with a hyphen in its name

I'm working on a servlet in Google App Engine. This servlet retrieves the data from the GAE's datastore; everything works fine when querying like "SELECT * FROM...". But when I want to filter it by a certain column, it does not work since the name of the column has a hypen. 开发者_运维技巧It is like the following:

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

How do I pass the propertyName with a hyphen?


java only accepts letters and digits the dollar sign "$", or the underscore character "_" like legal identifiers. So i believe that's not posible. Also did't work in python

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


The AppEngine datastore doesn't have rows or columns; it has models and properties.

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

You've described this yourself:

if I filter by a column called "field-1", it is kind of I was trying to subtract 1 from every returned value of the column called field


Is the addFilter method correctly enclosing the column name in single quotes? You might want to try adding them yourself. One can filter by things which are not keys in the database in GQL so this might be something that is expected of you.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜