Skip to content

Commit cee6303

Browse files
bbitoKevin Delisle
authored and
Kevin Delisle
committed
Add new type DateString to fromColumnValue
To sync with loopback-datasource-juggler #1356 which introduces new Type: DateString
1 parent d0a88ef commit cee6303

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lib/mysql.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,9 @@ MySQL.prototype.toColumnValue = function(prop, val) {
352352
}
353353
return val;
354354
}
355+
if (prop.type.name === 'DateString') {
356+
return val.when;
357+
}
355358
if (prop.type === Boolean) {
356359
return !!val;
357360
}
@@ -405,11 +408,11 @@ MySQL.prototype.fromColumnValue = function(prop, val) {
405408
val = String(val);
406409
break;
407410
case 'Date':
408-
411+
case 'DateString':
409412
// MySQL allows, unless NO_ZERO_DATE is set, dummy date/time entries
410413
// new Date() will return Invalid Date for those, so we need to handle
411414
// those separate.
412-
if (val == '0000-00-00 00:00:00') {
415+
if (!val || val == '0000-00-00 00:00:00' || val == '0000-00-00') {
413416
val = null;
414417
}
415418
break;

0 commit comments

Comments
 (0)