BadRequestError:不能在具有相等过滤器的属性上使用投影

时间:2013-03-23 13:33:36

标签: google-app-engine

在下面的代码片段中,当我尝试执行这两行时,我收到此错误:" BadRequestError:不能在具有相等过滤器"

的属性上使用投影
myname = self.response.get('state')

qy1 = db.GqlQuery(* SELECT name,phoneNumber,description,city,state FROM Table1 WHERE state =:1",myname)

在此之后我有一个for循环来迭代结果集 我在qy1:  (做一些json转储) 现在状态字段是一个StringProperty,甚至做str(myname)也会产生相同的结果。我一直在寻找他们说你应该做我以前做过的事情或做一些字符串'一些字符串',但是如果我把它改成那个我得到一个关于它不是列表的错误。

有什么建议吗?

完整堆栈跟踪是:

INFO     2013-03-23 14:12:08,756 dev_appserver.py:3103] "POST /sendNearByPlaces.html HTTP/1.1" 500 -
ERROR    2013-03-23 14:12:22,023 webapp2.py:1552] cannot use projection on a property with an equality filter
Traceback (most recent call last):
  File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2\webapp2.py", line 1535, in __call__
    rv = self.handle_exception(request, response, e)
  File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2\webapp2.py", line 1529, in __call__
    rv = self.router.dispatch(request, response)
  File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2\webapp2.py", line 1278, in default_dispatcher
    return route.handler_adapter(request, response)
  File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2\webapp2.py", line 1102, in __call__
    return handler.dispatch()
  File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2\webapp2.py", line 572, in dispatch
    return self.handle_exception(e, self.app.debug)
  File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2\webapp2.py", line 570, in dispatch
    return method(*args, **kwargs)
  File "C:\Users\defiant\Desktop\PythonServer\bar.py", line 368, in post
    for i in qy1:
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\ext\db\__init__.py", line 2326, in next
    return self.__model_class.from_entity(self.__iterator.next())
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\datastore\datastore_query.py", line 2892, in next
    next_batch = self.__batcher.next()
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\datastore\datastore_query.py", line 2754, in next
    return self.next_batch(self.AT_LEAST_ONE)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\datastore\datastore_query.py", line 2791, in next_batch
    batch = self.__next_batch.get_result()
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\api\apiproxy_stub_map.py", line 604, in get_result
    return self.__get_result_hook(self)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\datastore\datastore_query.py", line 2528, in __query_result_hook
    self._batch_shared.conn.check_rpc_success(rpc)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\datastore\datastore_rpc.py", line 1224, in check_rpc_success
    raise _ToDatastoreError(err)
BadRequestError: cannot use projection on a property with an equality filter
INFO     2013-03-23 14:12:22,075 dev_appserver.py:3103] "POST /sendNearByPlaces.html HTTP/1.1" 500 -

1 个答案:

答案 0 :(得分:2)

根据documentation“你不能投射同样过滤器中引用的属性。例如SELECT A FROM kind WHERE A = 1不支持,但SELECT A FROM kind WHERE B = 1或SELECT A FROM kind WHERE A> 1支持。“

[编辑] 简而言之:

qy1=db.GqlQuery(*SELECT name,phoneNumber,description,city,state FROM Table1 WHERE state =:1",myname) # WRONG 
qy1=db.GqlQuery(*SELECT name,phoneNumber,description,city       FROM Table1 WHERE state =:1",myname) # CORRECT

[/编辑]