Ordering on booleans works different with SQLite and Postgres
|Reported by:||anonymous||Owned by:||nobody|
|Component:||Database layer (models, ORM)||Version:||master|
|Cc:||herwin@…, josh.smeaton@…||Triage Stage:||Accepted|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
(And I expect all other databases behave like Postgres, but I haven't checked this)
When using a model with a boolean field, you can retreive a QuerySet and order it on the boolean field. In Postgres, the true comes first, in SQLite, false comes first.
Expected problem: SQLite uses integers for storing the booleans, even though the field type is called bool. 0 means false, 1 means true. So sorting on a boolean field behaves like a numeric sort, where 0 comes before 1.
Though the bug is actually caused by the strange behaviour of SQLite, it's far from optimal to get different behaviour just by switching the database backend.
Change History (6)
comment:1 Changed 4 years ago by
|Patch needs improvement:||unset|
comment:5 Changed 10 months ago by
|Status:||closed → new|
|Triage Stage:||Unreviewed → Accepted|
|Version:||1.4 → master|