AppEngine:查询数据存储中名称中带有连字符的列
我正在 Google App Engine 中开发 servlet。该 servlet 从 GAE 的数据存储中检索数据;当查询“SELECT * FROM...”时,一切正常。但是当我想按某个列过滤它时,它不起作用,因为该列的名称有连字符。如下所示:
Query query = new Query("tableName");
query.addFilter("col-name", Query.FilterOperator.EQUAL, filterValue);
如何传递带有连字符的 propertyName?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
java只接受字母和数字美元符号“$”或下划线字符“_”之类的合法标识符。
所以我相信这是不可能的。在 python 中也不起作用
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
AppEngine 数据存储区没有行或列;它有模型和属性。
定义数据类讨论了如何定义模型;需要注意的重要一点是,标识符名称的 Java 规则很重要,因为模型的每个属性在某些时候都会变成具有相同名称的 java 对象。
您自己已经描述过这一点:
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:
addFilter 方法是否正确地将列名称括在单引号中?您可能想尝试自己添加它们。人们可以按 GQL 中数据库中非键的内容进行过滤,因此这可能是您所期望的。
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.