You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Sequelize ignores milliseconds part of DATETIME in MySQL #4205
I'm using MySQL database with some columns of type DATETIME(3) (datetime with precision 3). Also in the entity model I have defined type as DATE(3). But after I set property of instance to time with millisecond part (e.g. entity.openedAt: "2015-08-29T08:39:08.12345Z"), sequelize generates SQL query, that truncates the millisecond part (...openedAt='2015-08-29 08:39:08'...).
MySQL 5.6.4 and up expands fractional seconds support for TIME, DATETIME, and TIMESTAMP values, with up to microseconds (6 digits) precision.
Dates don't support length at all right now - Actually I didn't even know that dates could have a length in mysql - I'm still on 5.5 :)
Anyhow, this should be pretty easy to do once #4186 has landed. Just change the stringify function for mysql date to check this.length to see if it should add milliseconds
Local mysql Ver 14.14 Distrib 5.6.27, for osx10.11 (x86_64) using EditLine wrapper
On server mysql Ver 14.14 Distrib 5.5.48, for Linux (x86_64) using readline 5.1
Activity
janmeier commentedon Jul 29, 2015
Dates don't support length at all right now - Actually I didn't even know that dates could have a length in mysql - I'm still on 5.5 :)
Anyhow, this should be pretty easy to do once #4186 has landed. Just change the stringify function for mysql date to check this.length to see if it should add milliseconds
Merge pull request #4854 from sobotklp/master
mfbx9da4 commentedon Feb 27, 2016
+1 also having this problem using sequelize 3.19.2 when should this be working?
produces
sobotklp commentedon Feb 27, 2016
How did you declare the column saved_timeout_time in your model?
sobotklp commentedon Feb 27, 2016
Also, which version of MySQL are you running?
mfbx9da4 commentedon Feb 28, 2016
Model declaration:
Local
mysql Ver 14.14 Distrib 5.6.27, for osx10.11 (x86_64) using EditLine wrapperOn server
mysql Ver 14.14 Distrib 5.5.48, for Linux (x86_64) using readline 5.1sobotklp commentedon Feb 28, 2016
In order to use millisecond-aware DATETIME columns, you'll have to use
type: DataTypes.DATE(3)mfbx9da4 commentedon Feb 28, 2016
Oh right sorry for wasting your time! Where is this documented?
sobotklp commentedon Mar 2, 2016
I don't believe it is documented anywhere, but I will change that tomorrow.
sobotklp commentedon Mar 12, 2016
#5575 adds documentation to the Data Types definitions list.
chaoyangnz commentedon Apr 22, 2022
Does this affect the MySQL column type or just how Sequelize is aware of milliseconds?
ephys commentedon Apr 22, 2022
Normally both