Re: [Django] #34606: Right() function on Oracle and SQLite returns improper value when the length is zero. (was: RIGHT function on Oracle returns improper value when the length is zero)

3 views
Skip to first unread message

Django

unread,
May 30, 2023, 4:57:02 AM5/30/23
to django-...@googlegroups.com
#34606: Right() function on Oracle and SQLite returns improper value when the
length is zero.
-------------------------------------+-------------------------------------
Reporter: Kacper Wolkiewicz | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 4.0
(models, ORM) |
Severity: Normal | Resolution:
Keywords: oracle right substr | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* stage: Unreviewed => Accepted


Comment:

Thanks for the report. SQLite is also affected. As far as I'm aware, it's
enough to pass a substring length, e.g.:
{{{#!diff
diff --git a/django/db/models/functions/text.py
b/django/db/models/functions/text.py
index fba2840c4b..f717213636 100644
--- a/django/db/models/functions/text.py
+++ b/django/db/models/functions/text.py
@@ -276,7 +276,7 @@ class Right(Left):

def get_substr(self):
return Substr(
- self.source_expressions[0], self.source_expressions[1] *
Value(-1)
+ self.source_expressions[0], self.source_expressions[1] *
Value(-1), self.source_expressions[1],
)


}}}
Would you like to prepare a patch? (a regression test is required.)

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

Reply all
Reply to author
Forward
0 new messages