Store NULL for empty date type values

This commit is contained in:
simov
2013-11-23 20:06:22 +02:00
parent a21671af88
commit 7ced603783
+7 -5
View File
@@ -159,11 +159,13 @@ function kvp (data, columns) {
}
function escape (value, type) {
return type.match(
new RegExp('char|varchar|tinytext|text|mediumtext|longtext|'+
'date|time|timestamp|datetime|year', 'i'))
? "\'"+value+"\'"
: value;
if (/char|varchar|tinytext|text|mediumtext|longtext/i.test(type)) {
return "\'"+value+"\'";
} else if (/date|time|timestamp|datetime|year/i.test(type)) {
return (value === '' || value === null) ? 'NULL' : "\'"+value+"\'";
} else {
return value;
}
}
// many-to-many helpers