#33517: Implied behavior of `__second` extractor inside of `F()` expressions 
does
not match documented behavior for at least PostgreSQL
-----------------------------------------+------------------------
               Reporter:  josefdlange    |          Owner:  nobody
                   Type:  Bug            |         Status:  new
              Component:  Documentation  |        Version:  4.0
               Severity:  Normal         |       Keywords:
           Triage Stage:  Unreviewed     |      Has patch:  0
    Needs documentation:  0              |    Needs tests:  0
Patch needs improvement:  0              |  Easy pickings:  0
                  UI/UX:  0              |
-----------------------------------------+------------------------
 In the Django documentation
 (https://docs.djangoproject.com/en/4.0/ref/models/querysets/#second) the
 `__second` extractor is implied to be dealing with integer values for
 second in a date time. In at least PostgreSQL, the values from
 `EXTRACT`ing `second` from a date time will include "any fractional
 seconds" (https://www.postgresql.org/docs/current/functions-datetime.html
 #FUNCTIONS-DATETIME-EXTRACT) which means it could be more specific than an
 integer.

 Because of the implication in Django's documentation, I had expected this
 filter to work as expected for a row whose `date_created` and
 `date_modified` are within a second of each other but a couple of
 milliseconds off:

 `.filter(date_created__second=F("date_modified__second"))`

 However, that ends up not being true given the Postgres behavior.

 My recommendation is merely a documentation update to highlight the
 discrepancy of behavior between a value coalesced to Python from the DB
 data, and how the column values are perceived on the database side within
 a query. I'm struggling for adequate language to explain in such a
 context, though :-P happy to discuss further and work together toward this
 improvement.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/33517>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/054.e5b88dcddc58965c1b0ab1d9682bd84a%40djangoproject.com.

Reply via email to