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

not boolean_column (None) is unexpected #232

Closed
luckydonald opened this Issue Feb 8, 2017 · 1 comment

Comments

Projects
None yet
2 participants
@luckydonald

luckydonald commented Feb 8, 2017

Hey, I'm havin unexpected behaviour with bool:

packs = orm.select(
        p for p in Pack if not p.nsfw
   )

Results in

SELECT "p"."url", "p"."title", "p"."nsfw", "p"."owner_id", "p"."first_seen", "p"."last_crawled", "p"."sticker_count"
FROM "pack" "p"
WHERE ("p"."nsfw")::int = 0

Which doesn't seem to cover the not None=>True case.

For postgres it could be like this Stackoverflow:

SELECT * FROM table_name WHERE (boolean_column IS NULL OR NOT boolean_column)

Indeed, a python workaround is:

p for p in Pack if p.nsfw is True or p.nsfw is None

@kozlovsky kozlovsky self-assigned this Mar 2, 2017

@kozlovsky kozlovsky added the bug label Mar 2, 2017

@kozlovsky kozlovsky added this to the 0.7.2 milestone Mar 2, 2017

@kozlovsky kozlovsky closed this in 87e3dcf Mar 2, 2017

@luckydonald

This comment has been minimized.

Show comment
Hide comment
@luckydonald

luckydonald commented Mar 3, 2017

👍

kozlovsky added a commit that referenced this issue Jul 17, 2017

Pony ORM Release 0.7.2 (2017-07-17)
# New features

* All arguments of db.bind() can be specified as keyword arguments. Previously Pony required the first positional argument which specified the database provider. Now you can pass all the database parameters using the dict: db.bind(**db_params). See https://docs.ponyorm.com/api_reference.html#Database.bind
* The `optimistic` attribute option is added https://docs.ponyorm.com/api_reference.html#cmdoption-arg-optimistic

# Bugfixes

* Fixes #219: when a database driver raises an error, sometimes this error was masked by the 'RollbackException: InterfaceError: connection already closed' exception. This happened because on error, Pony tried to rollback transaction, but the connection to the database was already closed and it masked the initial error. Now Pony displays the original error which helps to understand the cause of the problem.
* Fixes #276: Memory leak
* Fixes the __all__ declaration. Previously IDEs, such as PyCharm, could not understand what is going to be imported by 'from pony.orm import *'. Now it works fine.
* Fixes #232: negate check for numeric expressions now checks if value is zero or NULL
* Fixes #238, fixes #133: raise TransactionIntegrityError exception instead of AssertionError if obj.collection.create(**kwargs) creates a duplicate object
* Fixes #221: issue with unicode json path keys
* Fixes bug when discriminator column is used as a part of a primary key
* Handle situation when SQLite blob column contains non-binary value
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment