gpt4 book ai didi

python - 小马ORM : how to bypass limit in select

转载 作者:行者123 更新时间:2023-12-01 02:00:13 24 4
gpt4 key购买 nike

我想通过在多个条件下连接多个表来选择行...但它失败了。 PonyORM似乎限制了“if 语句”中的条件数量。

在 estore.py/test_queries (PY3.6, PonyORM 0.73) 中重现一个愚蠢示例:

result = select(c for c Customer if c.country!='A' and c.country!='A' and c.country!='A' and c.country!='A' and c.country!='A' and ...)

如果Nbr of c.country! = 'A' <= 24 ,它有效,但是 >= 25 ,反编译.py失败

如何绕过这个限制,对于具有大量表和条件的查询来说很烦人?

    Traceback               
<module> site-packages\pony\orm\examples\estore.py 183
test_queries <string> 2
new_func site-packages\pony\orm\core.py 460
test_queries site-packages\pony\orm\examples\estore.py 169
select <string> 2
cut_traceback site-packages\pony\utils\utils.py 58
select site-packages\pony\orm\core.py 5160
make_query site-packages\pony\orm\core.py 5147
decompile site-packages\pony\orm\decompiling.py 32
__init__ site-packages\pony\orm\decompiling.py 72
decompile site-packages\pony\orm\decompiling.py 90
TypeError: unsupported operand type(s) for <<: 'list' and 'int'

编辑:作为解决方法,我们可以通过添加 .where

来拆分查询
result = select(c for c Customer if c.country!='A' and c.country!='A' and c.country!='A' and c.country!='A' and c.country!='A').where(lambda c:c.country!='A' and c.country!='A')

最佳答案

这是 Python 3.6 中导致新字节码的错误。我们刚刚发布了fix on github .

关于python - 小马ORM : how to bypass limit in select,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49752761/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com