Hi,

I've opened a PR to add support for partial indexes in Django. It's on the right track, but I bumped into an issue that I need help with. On PostgreSQL, the cast that's introduced when doing something like:

Q(published__gt=datetime.date(2017, 10, 1))
=>
"table"."published" > '2017-10-01'::timestamp;

is unfortunate because it turns the function mutable, and the index can therefore not be created (exact error message can be seen in the Jenkins output). I think that's a plausible use-case for a partial index to limit on dates. Locally, I have two tests that filters on the "id" (I didn't see any reason to introduce a new integer column in either of the existing models; using "pk" instead raised a warning about the column not being present) and one that filters on a boolean. Both were suggestions from Markus Holtermann on what he had seen used in production. There was already something for text strings.

My problem is that I'm a bit in the wild how to battle the lookup-cast issue on PostgreSQL. I've already tried to study the Lookup-flow. I see two ways:

1. Describe this short-coming well in the documentation, and leave it like this. 2. Introduce a flag that can trigger the cast in this special case. I didn't check to see how much of this that's public API and how much that isn't. It's what I'd favour, but also more difficult.

There's enough time to the feature freeze of Django 2.2 to have the first option as a last resort.

The tests are still failing, and Oracle had some transaction problem, that I'm also very oblivious about. Again, error messages are in the Jenkins output.

Link to the PR: https://github.com/django/django/pull/10140
--
Med venlig hilsen / Kind regards,
Mads Jensen

     Saajan Fernandes: I think we forget things if there is nobody to
                       tell them.
     -- The Lunchbox (2013)

--
You received this message because you are subscribed to the Google Groups "Django 
developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/c465d23f-0090-ee6b-98b5-9b1202beda39%40inducks.org.
For more options, visit https://groups.google.com/d/optout.

Reply via email to