2012-08-14 16 views
1

嗨,我收到此錯誤。它在當地工作。 我剛剛刪除了appspot上的所有實體。BadRequestError:投影和keys_only不能同時設置

#query line 
sent_list = db.GqlQuery("SELECT email FROM MailListNew WHERE active = True") 
#error line 
sent_count = sent_list.count() 


projection and keys_only cannot both be set 
Traceback (most recent call last): 
    File "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 1511, in __call__ 
    rv = self.handle_exception(request, response, e) 
    File "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 1505, in __call__ 
    rv = self.router.dispatch(request, response) 
    File "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 1253, in default_dispatcher 
    return route.handler_adapter(request, response) 
    File "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 1077, in __call__ 
    return handler.dispatch() 
    File "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 547, in dispatch 
    return self.handle_exception(e, self.app.debug) 
    File "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 545, in dispatch 
    return method(*args, **kwargs) 
    File "/base/data/home/apps/s~merdiven-mailservice/1.361030076545076265/index.py", line 89, in post 
    sent_count = sent_list.count() 
    File "/base/python27_runtime/python27_lib/versions/1/google/appengine/ext/db/__init__.py", line 2120, in count 
    result = raw_query.Count(limit=limit, **kwargs) 
    File "/base/python27_runtime/python27_lib/versions/1/google/appengine/api/datastore.py", line 1670, in Count 
    batch = self.GetBatcher(config=config).next() 
    File "/base/python27_runtime/python27_lib/versions/1/google/appengine/datastore/datastore_query.py", line 2671, in next 
    return self.next_batch(self.AT_LEAST_ONE) 
    File "/base/python27_runtime/python27_lib/versions/1/google/appengine/datastore/datastore_query.py", line 2708, in next_batch 
    batch = self.__next_batch.get_result() 
    File "/base/python27_runtime/python27_lib/versions/1/google/appengine/api/apiproxy_stub_map.py", line 604, in get_result 
    return self.__get_result_hook(self) 
    File "/base/python27_runtime/python27_lib/versions/1/google/appengine/datastore/datastore_query.py", line 2450, in __query_result_hook 
    self._batch_shared.conn.check_rpc_success(rpc) 
    File "/base/python27_runtime/python27_lib/versions/1/google/appengine/datastore/datastore_rpc.py", line 1216, in check_rpc_success 
    raise _ToDatastoreError(err) 
BadRequestError: projection and keys_only cannot both be set 

回答

2

您需要查詢更改爲:

sent_list = db.GqlQuery("SELECT * FROM MailListNew WHERE active = True") 

或(更好):

sent_list = db.GqlQuery("SELECT __key__ FROM MailListNew WHERE active = True") 
+0

我需要循環每封電子郵件,所以我第一次嘗試查詢和現在工作的感謝。 – 2012-08-14 11:21:07