Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(data-types): unnecessary warning when getting data with DATE dataTypes #13712

Merged
merged 2 commits into from Nov 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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