endlessm / azafea

Service to track device activations and usage metrics
Mozilla Public License 2.0
10 stars 2 forks source link

model: Fix queries on nulleable booleans #40

Closed bochecha closed 5 years ago

bochecha commented 5 years ago

The NullableBoolean type allows inserting records with a column which can be either True, False or None, while properly handling unicity constraints.

To do that is uses a string enum with three states ('true', 'false' and 'unknown') to the Python values (True, False and None).

However, when trying to filter queries on such a column being None in Python, SQLAlchemy would generate an SQL with "column IS NULL", instead or the expected "column = 'unknown'.

This commit fixes that.

Fortunately, we had never done such queries in Python yet, so this bug didn't actually cause any trouble.