mattiaslinnap / django-partial-index

PostgreSQL and SQLite partial index support for Django
BSD 3-Clause "New" or "Revised" License
116 stars 12 forks source link

Allow adding separate where='sql expression' for PostgreSQL and SQLite #1

Closed mattiaslinnap closed 7 years ago

mattiaslinnap commented 7 years ago

The where='sql expression' is inserted directly into the CREATE INDEX statement when a migration runs. It must be valid for the currently active database backend.

While the django-partial-index project supports both PostgreSQL and SQLite, they have slightly different expected syntax for some expressions.

In a particularly common case, they differ in valid boolean literals: SQLite only accepts 0 and 1 as numbers, and PostgreSQL only accepts TRUE, FALSE and a few string values: https://www.postgresql.org/docs/9.1/static/datatype-boolean.html

This means that where-expressions for the common case of filtering on a boolean flag need two different expressions in a project that uses PostgreSQL in production and SQLite in testing.

Proposed solution:

mattiaslinnap commented 7 years ago

Fixed in version 0.3.0