Merge lp://staging/~cjwatson/storm/is-and-is-not-operators into lp://staging/storm
Status: | Merged |
---|---|
Merged at revision: | 577 |
Proposed branch: | lp://staging/~cjwatson/storm/is-and-is-not-operators |
Merge into: | lp://staging/storm |
Diff against target: |
233 lines (+173/-0) 3 files modified
NEWS (+1/-0) storm/expr.py (+70/-0) storm/tests/expr.py (+102/-0) |
To merge this branch: | bzr merge lp://staging/~cjwatson/storm/is-and-is-not-operators |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Andrey Fedoseev (community) | Approve | ||
Review via email: mp+431754@code.staging.launchpad.net |
Commit message
Add storm.expr.Is and storm.expr.IsNot operators.
Description of the change
Launchpad has had custom `IsTrue` and `IsFalse` operators for a while, because there are a few places where `expr` or `expr == True` (or the equivalents for False) don't quite do what we need: for example, if you're working with a nullable boolean column, then SQL NULL semantics mean that `expr = TRUE` or `expr = FALSE` return NULL when `expr` is NULL, which can be undesirable at times.
In addition, `==` and `!=` comparisons with True/False/None are typically picked up as errors by modern linters, since in normal Python code they should use `is` or `is not` or simple boolean tests instead. Having to override this is an annoyance.
Compare https:/
I've checked that current versions of all the databases currently supported by Storm (PostgreSQL, MySQL, and SQLite) support all the resulting expressions, although in the case of SQLite it does need at least version 3.23.0 (released in 2018).