#29222: Substr on NULL values returns incorrect results with pattern lookups.
-------------------------------------+-------------------------------------
Reporter: Mariusz Felisiak | Owner: Siddharth
| Panditrao
Type: Bug | Status: closed
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution: wontfix
Keywords: Oracle | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):
* resolution: => wontfix
* stage: Accepted => Unreviewed
* status: assigned => closed
Comment:
Replying to [comment:7 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` than change
things for an arguably worst default.
Yes, exactly, that's why I didn't fix this for so long.
--
Ticket URL: <https://code.djangoproject.com/ticket/29222#comment:8>
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/0107019b3fe9f379-88b39502-ca90-4f95-8975-f15d4325f3b8-000000%40eu-central-1.amazonses.com.