ponyORM:如何在select中绕过限制

时间:2018-04-10 11:44:00

标签: python ponyorm

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

要在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,则在decompiling.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')

1 个答案:

答案 0 :(得分:2)

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