#23434: Incorrect parameter coercion for bool in Oracle backend
----------------------------------------------+----------------------------
Reporter: jarshwah | Owner: nobody
Type: Uncategorized | Status: new
Component: Database layer (models, ORM) | Version: master
Severity: Normal | Keywords: oracle backend
Triage Stage: Unreviewed | orm
Easy pickings: 1 | Has patch: 0
| UI/UX: 0
----------------------------------------------+----------------------------
The following code exists in backends.oracle.base.OracleParam:
{{{
# Oracle doesn't recognize True and False correctly in Python 3.
# The conversion done below works both in 2 and 3.
if param is True:
param = "1"
elif param is False:
param = "0"
}}}
I believe the conversion should be to the integers `1` and `0`
respectively, rather than strings. This hasn't manifested as a problem
before, but it is causing problems when using user defined boolean
annotations in #14030. The string "1" is being returned rather than the
integer 1 so the field converters aren't receiving the type they expect
(integers) and do no conversions.
The alternative to changing the code above would be to change the field
converter to check for `value in ("1","0")` and then do the relevant
bool(int()) conversion, but I think that's working around the actual
problem.
Happy to put a patch together. I just wanted to get some buy in that this
needs fixing first, and that the approach above should be valid. I'm not
sure whether OracleParam can work with just strings or not.
--
Ticket URL: <https://code.djangoproject.com/ticket/23434>
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 post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/051.9b1015d7e06759cbef8bfbba65f0ae04%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.