577
|
|
Add storm.expr.Is and storm.expr.IsNot operators.
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://docs.sqlalchemy.org/en/20/core/operators.html#identity-comparisons, although SQLAlchemy is more permissive; it seems to be happy to compile anything on the right-hand-side of `IS` or `IS NOT` and leave it up to the database. Since we already have to take some care with how booleans are rendered, and there's no guarantee that the spelling of `IS TRUE` etc. is going to match the way that boolean values themselves are spelled, I thought it better to limit the set of right-hand-side expressions that we will compile.
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).
|
Colin Watson |
|
1 year ago
|
|
|
576
|
|
|
Colin Watson |
|
2 years ago
|
|
|
575
|
|
|
Colin Watson |
|
2 years ago
|
|
|
574
|
|
|
Colin Watson |
|
2 years ago
|
|
|
573
|
|
|
Colin Watson |
|
3 years ago
|
|
|
572
|
|
|
Colin Watson |
|
3 years ago
|
|
|
571
|
|
|
Colin Watson |
0.25 |
3 years ago
|
|
|
570
|
|
|
Colin Watson |
|
3 years ago
|
|
|
569
|
|
|
Colin Watson |
|
3 years ago
|
|
|
568
|
|
|
Colin Watson |
|
3 years ago
|
|
|
567
|
|
|
Colin Watson |
|
3 years ago
|
|
|
566
|
|
|
Colin Watson |
|
3 years ago
|
|
|
565
|
|
|
Colin Watson |
0.24 |
3 years ago
|
|
|
564
|
|
|
Colin Watson |
|
3 years ago
|
|
|
563
|
|
|
Colin Watson |
|
3 years ago
|
|
|
562
|
|
|
Colin Watson |
|
3 years ago
|
|
|
561
|
|
|
Colin Watson |
|
3 years ago
|
|
|
560
|
|
|
Colin Watson |
|
3 years ago
|
|
|
559
|
|
|
Colin Watson |
|
3 years ago
|
|
|
558
|
|
|
Colin Watson |
|
3 years ago
|
|
|