Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/google-app-engine/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python ndb为-BadQueryError的GAE中出错:无法将FalseNode转换为谓词_Python_Google App Engine_App Engine Ndb - Fatal编程技术网

Python ndb为-BadQueryError的GAE中出错:无法将FalseNode转换为谓词

Python ndb为-BadQueryError的GAE中出错:无法将FalseNode转换为谓词,python,google-app-engine,app-engine-ndb,Python,Google App Engine,App Engine Ndb,我有一个应用程序运行在谷歌应用程序引擎与python。 模型类从ndb(google.appengine.ext.ndb)类扩展而来 我的一个视图对数据库进行异步调用,或多或少类似于: # ExerciseListLog is a ndb model class # start_current, end_current are dates # student_id is a string # contents is a list of keys exercise_log_query = Exe

我有一个应用程序运行在谷歌应用程序引擎与python。 模型类从ndb(google.appengine.ext.ndb)类扩展而来

我的一个视图对数据库进行异步调用,或多或少类似于:

# ExerciseListLog is a ndb model class
# start_current, end_current are dates
# student_id is a string
# contents is a list of keys

exercise_log_query = ExerciseListLog.query(ndb.AND(ExerciseListLog.creation >= start_current,
    ExerciseListLog.creation < end_current,
    ExerciseListLog.user_id == student_id))
exercise_log_query = exercise_log_query.filter(ExerciseListLog.content.IN(contents))

future = exercise_log_query.count_async()

count = future.get_result() # this throws BadQueryError
#ExerciseListLog是一个ndb模型类
#当前开始日期、当前结束日期是日期
#学生id是一个字符串
#内容是一个键列表
exercise\u log\u query=ExerciseListLog.query(ndb.AND)(ExerciseListLog.creation>=start\u current,
ExerciseListLog.creation
这在get_result()上引发错误: BadQueryError:无法将FalseNode转换为谓词

但这只有在我将代码部署到谷歌云时才会发生。当我在本地运行它时,它工作正常

我不知道这个错误意味着什么,在谷歌上查找也没什么帮助。 有人知道这里出了什么事吗

这是GAE日志中的完整stacktrace

Traceback (most recent call last):
  File "/base/data/home/apps/s~qmagtest/1.366092357976105290/zen/web/gae/convention.py", line 48, in make_convention
    method(*args, **kwargs)
  File "/base/data/home/apps/s~qmagtest/1.366092357976105290/core/web/qmhandler.py", line 48, in wrapper
    return method(self, *args, **kwargs)
  File "/base/data/home/apps/s~qmagtest/1.366092357976105290/core/user/login/security.py", line 36, in wrapper
    method(self, *args, **kwargs)
  File "/base/data/home/apps/s~qmagtest/1.366092357976105290/core/user/security.py", line 17, in wrapper
    method(self, *args_inner, **kwargs)
  File "/base/data/home/apps/s~qmagtest/1.366092357976105290/plugins/web/desempenho/estatisticas.py", line 127, in class_activities
    school_class.content)
  File "/base/data/home/apps/s~qmagtest/1.366092357976105290/plugins/web/desempenho/estatisticas.py", line 178, in _get_exercise_video_and_total_weekly_series
    exercise_log_count = exercise_count_futures[i].get_result()
  File "/python27_runtime/python27_lib/versions/1/google/appengine/ext/ndb/tasklets.py", line 325, in get_result
    self.check_success()
  File "/python27_runtime/python27_lib/versions/1/google/appengine/ext/ndb/tasklets.py", line 371, in _help_tasklet_along
    value = gen.send(val)
  File "/python27_runtime/python27_lib/versions/1/google/appengine/ext/ndb/query.py", line 1227, in _count_async
    dsquery = self._get_query(conn)
  File "/python27_runtime/python27_lib/versions/1/google/appengine/ext/ndb/query.py", line 873, in _get_query
    filters = filters._to_filter()
  File "/python27_runtime/python27_lib/versions/1/google/appengine/ext/ndb/query.py", line 599, in _to_filter
    for node in self.__nodes
  File "/python27_runtime/python27_lib/versions/1/google/appengine/ext/ndb/query.py", line 600, in <genexpr>
    if isinstance(node, PostFilterNode) == post))
  File "/python27_runtime/python27_lib/versions/1/google/appengine/ext/ndb/query.py", line 425, in _to_filter
    'Cannot convert FalseNode to predicate')
BadQueryError: Cannot convert FalseNode to predicate
回溯(最近一次呼叫最后一次):
文件“/base/data/home/apps/s~qmagtest/1.366092357976105290/zen/web/gae/convention.py”,make_约定第48行
方法(*args,**kwargs)
文件“/base/data/home/apps/s~qmagtest/1.366092357976105290/core/web/qmhandler.py”,第48行,在包装器中
返回方法(self、*args、**kwargs)
包装器中的文件“/base/data/home/apps/s~qmagtest/1.366092357976105290/core/user/login/security.py”,第36行
方法(self、*args、**kwargs)
包装器中的文件“/base/data/home/apps/s~qmagtest/1.366092357976105290/core/user/security.py”,第17行
方法(self,*args_inner,**kwargs)
文件“/base/data/home/apps/s~qmagtest/1.366092357976105290/plugins/web/desempenho/estatisticas.py”,第127行,课堂活动
学校(课程内容)
文件“/base/data/home/apps/s~qmagtest/1.366092357976105290/plugins/web/desempenho/estaticas.py”,第178行,在“获取”、“练习”、“视频”和“每周总计”系列中
exercise\u log\u count=exercise\u count\u futures[i]。获取结果()
文件“/python27_runtime/python27_lib/versions/1/google/appengine/ext/ndb/tasklets.py”,第325行,在get_result中
self.check_success()
文件“/python27_runtime/python27_lib/versions/1/google/appengine/ext/ndb/tasklets.py”,第371行,在“帮助”tasklet中
值=gen.send(val)
文件“/python27\u runtime/python27\u lib/versions/1/google/appengine/ext/ndb/query.py”,第1227行,异步计数
dsquery=self.\u获取\u查询(conn)
文件“/python27_runtime/python27_lib/versions/1/google/appengine/ext/ndb/query.py”,第873行,在_get_query中
过滤器=过滤器。_至_过滤器()
文件“/python27_runtime/python27_lib/versions/1/google/appengine/ext/ndb/query.py”,第599行,在_to_过滤器中
用于自组织中的节点。\uuu节点
文件“/python27_runtime/python27_lib/versions/1/google/appengine/ext/ndb/query.py”,第600行,在
如果isinstance(节点,PostFilterNode)=post))
文件“/python27_runtime/python27_lib/versions/1/google/appengine/ext/ndb/query.py”,第425行,在_to_过滤器中
'无法将FalseNode转换为谓词')
BadQueryError:无法将FalseNode转换为谓词
更新:

我发现如果我删除该行:

exercise_log_query = exercise_log_query.filter(ExerciseListLog.content.IN(contents))
那就行了

因此,错误与对数据库的异步调用无关。 之所以会出现这种情况,是因为谷歌AppEngine只在每个查询的一个字段中支持不等式过滤器。 显然,使用“content.IN”算作第二个不等式,这是不允许的

这个错误信息可能更好


更新:

事实证明Guido是对的,而我上面的解释是错误的。
content.IN正在工作,因为
内容
不是空的。

我怀疑问题在于内容是一个空列表。这几乎是FalseNode出现的唯一原因。(另一个是调用AND(),没有参数。)你观察到删除这一行证实了我的直觉。你可能没想到会发生这种情况,在你的本地测试中,它从未发生过。。。您可能需要调试该列表中的代码


我同意错误信息可能更好。

你可能是对的。我会测试你的假设并发回。谢谢圭多,你是对的。我可以使用content.IN,在这种情况下,只要
contents
不是空的。谢谢这很有帮助。谢谢!