Details
-
Sub-task
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
2.0
-
None
-
MySQL, PostgreSQL, Microsoft SQL, Oracle
-
MOODLE_20_STABLE
-
MOODLE_20_STABLE
Description
Expected behaviour to get cross-db support is to automatically cast empty strings to 0 in the following functions:
- insert_record
- update_record
- set_field
Rationale: DBs are idiot:
- MSSQL allows empties on int fields and saves them as 0, but not in decimal fields no matter of the nullability of the field)
- Oracle allows empties on int fields and saves them as NULL and only in NOT NULL fields. Same for decimal fields.
- MySQL doesn't allow empties in int/decimal fields (strict mode). Error.
- PG doesn't allow empties in int/decimal fields). Error.
So I guess we only can move to the "perform casting" alternative. Is the only that will work cross-db. The other (not perform casting) won't work as far as MSSQL and Oracle sometimes accept those empty strings.