Skip to content

Commit

Permalink
fix(data-types): unnecessary warning when getting data with DATE data…
Browse files Browse the repository at this point in the history
…Types (#13712)

* fix(data-types): unnecessary error when getting data with DATE dataTypes

* fix(data-types): date stringify mariadb
  • Loading branch information
fzn0x committed Nov 27, 2021
1 parent 2d7b865 commit 121884b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
8 changes: 6 additions & 2 deletions lib/dialects/mariadb/data-types.js
Expand Up @@ -54,8 +54,12 @@ module.exports = BaseTypes => {
return this._length ? `DATETIME(${this._length})` : 'DATETIME';
}
_stringify(date, options) {
date = this._applyTimezone(date, options);
return date.format('YYYY-MM-DD HH:mm:ss.SSS');
if(_.isDate(date)){
date = this._applyTimezone(date, options);
return date.format('YYYY-MM-DD HH:mm:ss.SSS');
}

return date;
}
static parse(value, options) {
value = value.string();
Expand Down
14 changes: 9 additions & 5 deletions lib/dialects/mysql/data-types.js
Expand Up @@ -53,12 +53,16 @@ module.exports = BaseTypes => {
return this._length ? `DATETIME(${this._length})` : 'DATETIME';
}
_stringify(date, options) {
date = this._applyTimezone(date, options);
// Fractional DATETIMEs only supported on MySQL 5.6.4+
if (this._length) {
return date.format('YYYY-MM-DD HH:mm:ss.SSS');
if(_.isDate(date)){
date = this._applyTimezone(date, options);
// Fractional DATETIMEs only supported on MySQL 5.6.4+
if (this._length) {
return date.format('YYYY-MM-DD HH:mm:ss.SSS');
}
return date.format('YYYY-MM-DD HH:mm:ss');
}
return date.format('YYYY-MM-DD HH:mm:ss');

return date;
}
static parse(value, options) {
value = value.string();
Expand Down

0 comments on commit 121884b

Please sign in to comment.