﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
34606	Right() function on Oracle and SQLite returns improper value when the length is zero.	Kacper Wolkiewicz	Kacper Wolkiewicz	"Hi
I have found that the `RIGHT` database function on Oracle returns the whole string instead of empty string when the given length is 0. You can't explicitly give 0 to the `RIGHT` function, but it may be computed by the database. Basic example (you can use any model with a CharField):

{{{#!python
from django.db.models.functions import Right, Length

MyModel.objects.annotate(suffix=Right(""foo"", Length(""foo"") - Length(""foo"")))
}}}

On PostgreSQL this will return an empty string under the field `suffix`, but on Oracle this will return the whole contents of the field `foo`. This is because Django uses the `SUBSTR` function on Oracle by multiplying the given length value by -1 and giving it as a `position` argument. I think it is not intended behavior and it should return the empty string as PostgreSQL does. Or at least be documented as a Note in the `Right` function documentation."	Bug	closed	Database layer (models, ORM)	4.0	Normal	fixed	oracle right substr		Ready for checkin	1	0	0	0	0	0
