1

我想通过在多个条件下连接多个表来选择行......它失败了。 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,它在 decompile.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')
4

1 回答 1

2

这是 Python 3.6 中导致新字节码事物的错误。我们刚刚在 github 上发布了修复程序

于 2018-06-22T15:17:43.593 回答