#29222: Substr on NULL values returns incorrect results with pattern lookups.
-------------------------------------+-------------------------------------
     Reporter:  Mariusz Felisiak     |                    Owner:  Siddharth
                                     |  Panditrao
         Type:  Bug                  |                   Status:  assigned
    Component:  Database layer       |                  Version:  dev
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:  Oracle               |             Triage Stage:  Accepted
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Comment (by Simon Charette):

 I left a note to this effect [https://forum.djangoproject.com/t/fix-
 oracle-bug-where-substr-null-with-pattern-lookups-matches-all-rows-
 instead-of-none/43757 on the forum] but I'm afraid there isn't much we can
 do here given `__startswith` and related lookups
 [https://dryorm.xterm.info/ticket-29222 have historically accepted an
 empty strings as their right-side-hand to match all rows].

 Because `''` and `NULL` are the same thing on Oracle we have to choose; we
 can't return all rows in the first case and no rows in the second like on
 all other backends.

 Given these lookups are meant to treat with text fields left-hand-sides in
 which
 
[https://docs.djangoproject.com/en/6.0/ref/models/fields/#django.db.models.Field.null
 we document that storing `NULL` is an anti-pattern]

 > Avoid using `null` on string-based fields such as `CharField` and
 `TextField`. The Django convention is to use an empty string, not `NULL`,
 as the “no data” state for string-based fields.

 and things have been working this way on Oracle since their inception I'd
 be more inclined to wont-fix this ticket and accept it as a unfortunate
 side effect of `interprets_empty_strings_as_nulls`.
-- 
Ticket URL: <https://code.djangoproject.com/ticket/29222#comment:7>
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 visit 
https://groups.google.com/d/msgid/django-updates/0107019b3fdd002d-a658082e-ba7e-4fa4-afff-f7f6532cc211-000000%40eu-central-1.amazonses.com.

Reply via email to