Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

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

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

alsmirn opened this issue Oct 25, 2014 · 2 comments

Comments

@alsmirn
Copy link

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
Copy link
Member

Thanks for the reporting, should work now

@alsmirn
Copy link
Author

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants