Handle "None" when type is <type: 'str'>
|Reported by:||Ari Kivimäki <arinium@…>||Owned by:||adrian|
|Component:||Database layer (models, ORM)||Version:||master|
|Severity:||Keywords:||None NoneType str String|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
Apparently at least pysqlite 2.3.5 (with Python 2.5) returns "None" (<type: 'str'>) instead of None (<type: 'NoneType'>) when a field is NULL. This causes problems with Django when conditional statement compares solely to NoneType and passes string values. Fortunately this is easily fixed: if the conditional statement (if not s: return None) on db/backends/util.py line 73 is added another condition to satisfy str type "None" (if not s or s == "None": return None).