IN / NOT IN clauses works different with empty sequence #89

Closed
alsmirn opened this Issue Oct 25, 2014 · 2 comments

Projects

None yet

2 participants

@alsmirn
alsmirn commented Oct 25, 2014

Examples:

persons_allowed = ()
select(p for p in Person if p.id in persons_allowed)

OK

But

persons_allowed = ()
select(p for p in Person if p.id not in persons_allowed)

Traceback

    sql, adapter = database.provider.ast2sql(sql_ast)
  File "/home/alexey/workspace/tt/venv/local/lib/python2.7/site-packages/pony/orm/dbapiprovider.py", line 178, in ast2sql
    builder = provider.sqlbuilder_cls(provider, ast)
  File "/home/alexey/workspace/tt/venv/local/lib/python2.7/site-packages/pony/orm/sqlbuilding.py", line 150, in __init__
    builder.result = flat(builder(ast))
  File "/home/alexey/workspace/tt/venv/local/lib/python2.7/site-packages/pony/orm/sqlbuilding.py", line 177, in __call__
    return method(*ast[1:])
  File "/home/alexey/workspace/tt/venv/local/lib/python2.7/site-packages/pony/orm/sqlbuilding.py", line 210, in SELECT
    result = builder.subquery(*sections)
  File "/home/alexey/workspace/tt/venv/local/lib/python2.7/site-packages/pony/orm/sqlbuilding.py", line 206, in subquery
    result = [ builder(s) for s in sections ]
  File "/home/alexey/workspace/tt/venv/local/lib/python2.7/site-packages/pony/orm/sqlbuilding.py", line 177, in __call__
    return method(*ast[1:])
  File "/home/alexey/workspace/tt/venv/local/lib/python2.7/site-packages/pony/orm/sqlbuilding.py", line 282, in WHERE
    extend((builder(conditions[0]), '\n'))
  File "/home/alexey/workspace/tt/venv/local/lib/python2.7/site-packages/pony/orm/sqlbuilding.py", line 177, in __call__
    return method(*ast[1:])
  File "/home/alexey/workspace/tt/venv/local/lib/python2.7/site-packages/pony/orm/sqlbuilding.py", line 385, in NOT_IN
    if not x: throw(AstError, 'Empty IN clause')
  File "/home/alexey/workspace/tt/venv/local/lib/python2.7/site-packages/pony/utils.py", line 91, in throw
    raise exc
pony.orm.sqlbuilding.AstError: Empty IN clause
@kozlovsky kozlovsky closed this in 356743e Oct 28, 2014
@kozlovsky
Contributor

Thanks for the reporting, should work now

@alsmirn
alsmirn commented Oct 28, 2014

it works, thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment