Repository navigation
Conversation
|
@papb |
16df58b to
a1d72e6
Compare
Codecov Report
@@ Coverage Diff @@
## master #11409 +/- ##
==========================================
- Coverage 92.49% 89.58% -2.92%
==========================================
Files 91 92 +1
Lines 8866 9054 +188
==========================================
- Hits 8201 8111 -90
- Misses 665 943 +278
Continue to review full report at Codecov.
|
|
Hi @dead, I'm confused... You said the following in a comment in the issue:
However your PR does not implement my first suggestion. Why? |
|
@papb If you have any other suggestion than using Btw, not sure how to create a test for this. I was able to reproduce the error running the current data-types test with a custom timezone |
|
Thanks! The current solution is fine then.
|
|
This commit solved my problem, in my case. It makes sense to convert without UTC to an attribute that is only date. Using DATEONLY, the date was recorded correctly, for example '2020-5-1'. However, when consulting the object, it resulted in '2020-4-1' (always one day less) For now I had to change the original file inside node_modules.(\node_modules\sequelize\lib\dialects\mssql\data-types.js ) Could this pull request be approved to have this correction in a next version? |
|
👍 This fixes an issue for me. How can we get it merged in? |
|
I second @xjpro, this fixes a problem for my team as well. |
|
This fix all my problems with mssql and Sequelize.DATEONLY. |
|
@dead Is this bit of code needed to make it pass the string test? |
|
I just realized that the code posted above by @emmiranda is slightly different than the code in this pull request. I have confirmed that the following from @emmiranda does indeed work: I have also successfully tested the code in this pull request from @dead, which is: I have successfully used patch-package to implement the code from this pull request as a workaround for now. |
tonyguinta
left a comment
There was a problem hiding this comment.
I have confirmed that this code solves issue 10982.
|
I have also tested this independently in version 5.22.3 |
|
Meanwhile i have done the following and this will overwrite the parsing function to work correctly. const moment = require('moment'); sequelize.DataTypes.mssql.DATEONLY.parse = function (value) { |
Yeah, it works well when we have proper dates in DB and just need to display it properly, but it also might need to patch So complete solution for me is: const moment = require('moment');
const sequelize = require('sequelize');
sequelize.DataTypes.mssql.DATEONLY.parse = function (value) {
return moment.utc(value).format('YYYY-MM-DD');
};
sequelize.DataTypes.mssql.DATEONLY.prototype._stringify= function (value) {
return moment.utc(value).format('YYYY-MM-DD');
};
sequelize.DataTypes.mssql.DATEONLY.prototype._sanitize= function (value) {
if ((!options || (options && !options.raw)) && !!value) {
return moment.utc(value).format('YYYY-MM-DD');
}
return value;
};An alternative approach - set default timezone for moment module used by sequelize: require("sequelize/node_modules/moment").tz.setDefault('UTC");so, we won't need to patch any existing methods: internal sequelize Both approaches work for sequelize 6.3.5 |
|
Hey there :) First of all: Thanks a bunch for your contribution to Sequelize! Much appreciated! A couple of months ago, we have switched from master to main branch as our primary development branch and hence this PR is now outdated :( If you still think this change is making sense, please consider recreating the PR against ✌️ |
Pull Request check-list
Please make sure to review and check all of these items:
npm run testornpm run test-DIALECTpass with this change (including linting)?Description of change
Fix #10982 - Removed the DATAONLY extended class from MSSQL dialect.