int_to_boolean / boolean_to_int don't coerce to 1/0
they likely should, particularly given that the C processor checks for 1/0 on the way back and MySQL doesn't enforce the CHECK constraint if present.
Comments (6)
-
reporter -
reporter -
reporter note that the first version here had boolean_to_int accepting any value; I just switched it to reject values that are outside None/True/False/1/0. Though this might cause problems the way ENUM checking did as well , e.g. if someone is doing "boolean_col > 10" or something like that.
-
reporter oslo.db even has a test for "boolean accepts 10" so i think that's an indicator of leaving the boolean interpretation pretty open on the Python side, the gerrit passed for the first version.
-
reporter - changed status to resolved
Make boolean processors consistent between Py/C; coerce to 1/0
The processing performed by the :class:
.Boolean
datatype for backends that only feature integer types has been made consistent between the pure Python and C-extension versions, in that the C-extension version will accept any integer value from the database as a boolean, not just zero and one; additionally, non-boolean integer values being sent to the database are coerced to exactly zero or one, instead of being passed as the original integer value.Change-Id: I01e647547fd7047bd549dd70e1fa202c51e8328b Fixes:
#3730→ <<cset 7c74d702a963>>
-
reporter Make boolean processors consistent between Py/C; coerce to 1/0
The processing performed by the :class:
.Boolean
datatype for backends that only feature integer types has been made consistent between the pure Python and C-extension versions, in that the C-extension version will accept any integer value from the database as a boolean, not just zero and one; additionally, non-boolean integer values being sent to the database are rejected if they are outside of the range 1 / 0, without requiring the use of a CHECK constraint.Change-Id: I01e647547fd7047bd549dd70e1fa202c51e8328b Fixes:
#3730→ <<cset ae41612744a5>>
- Log in to comment
additionally, the C extension and the non-C processor are inconsistent; the C ext raises if the value isn't 1/0 and the non-C does not.