不要怂,就是干,撸起袖子干!

Commit 8c2c1291 by Harshith Kashyap Committed by Sushant

MSSQL - Changed DataTypes.DATE to use DATETIMEOFFSET datatype (#7201)

1 parent c3afda63
# Future # Future
- [CHANGED] `DataTypes.DATE` to use `DATETIMEOFFSET` [MSSQL] [#5403](https://github.com/sequelize/sequelize/issues/5403)
- [FIXED] Properly pass options to `sequelize.query` in `removeColumn` [MSSQL] [#7193](https://github.com/sequelize/sequelize/pull/7193) - [FIXED] Properly pass options to `sequelize.query` in `removeColumn` [MSSQL] [#7193](https://github.com/sequelize/sequelize/pull/7193)
- [FIXED] Updating `VIRTUAL` field throw `ER_EMPTY_QUERY` [#6356](https://github.com/sequelize/sequelize/issues/6356) - [FIXED] Updating `VIRTUAL` field throw `ER_EMPTY_QUERY` [#6356](https://github.com/sequelize/sequelize/issues/6356)
- [FIXED] Fix `Instance.decrement` precision problems [#7112](https://github.com/sequelize/sequelize/pull/7112) - [FIXED] Fix `Instance.decrement` precision problems [#7112](https://github.com/sequelize/sequelize/pull/7112)
...@@ -50,6 +51,7 @@ ...@@ -50,6 +51,7 @@
## BC breaks: ## BC breaks:
- `DATEONLY` now returns string in `YYYY-MM-DD` format rather than `Date` type - `DATEONLY` now returns string in `YYYY-MM-DD` format rather than `Date` type
- With `BelongsToMany` relationships `add/set/create` setters now set `through` attributes by passing them as `options.through` (previously second argument was used as `through` attributes, now its considered `options` with `through` being a sub option) - With `BelongsToMany` relationships `add/set/create` setters now set `through` attributes by passing them as `options.through` (previously second argument was used as `through` attributes, now its considered `options` with `through` being a sub option)
- `DataTypes.DATE` now uses `DATETIMEOFFSET` instead of `DATETIME2` sql datatype in case of MSSQL to record timezone [#5403](https://github.com/sequelize/sequelize/issues/5403)
# 4.0.0-2 # 4.0.0-2
- [ADDED] include now supports string as an argument (on top of model/association), string will expand into an association matched literally from Model.associations - [ADDED] include now supports string as an argument (on top of model/association), string will expand into an association matched literally from Model.associations
......
...@@ -7,7 +7,7 @@ const inherits = require('../../utils/inherits'); ...@@ -7,7 +7,7 @@ const inherits = require('../../utils/inherits');
module.exports = BaseTypes => { module.exports = BaseTypes => {
const warn = BaseTypes.ABSTRACT.warn.bind(undefined, 'https://msdn.microsoft.com/en-us/library/ms187752%28v=sql.110%29.aspx'); const warn = BaseTypes.ABSTRACT.warn.bind(undefined, 'https://msdn.microsoft.com/en-us/library/ms187752%28v=sql.110%29.aspx');
BaseTypes.DATE.types.mssql = [42]; BaseTypes.DATE.types.mssql = [43];
BaseTypes.STRING.types.mssql = [231, 173]; BaseTypes.STRING.types.mssql = [231, 173];
BaseTypes.CHAR.types.mssql = [175]; BaseTypes.CHAR.types.mssql = [175];
BaseTypes.TEXT.types.mssql = false; BaseTypes.TEXT.types.mssql = false;
...@@ -126,14 +126,7 @@ module.exports = BaseTypes => { ...@@ -126,14 +126,7 @@ module.exports = BaseTypes => {
inherits(DATE, BaseTypes.DATE); inherits(DATE, BaseTypes.DATE);
DATE.prototype.toSql = function toSql() { DATE.prototype.toSql = function toSql() {
return 'DATETIME2'; return 'DATETIMEOFFSET';
};
DATE.prototype._stringify = function _stringify(date, options) {
date = this._applyTimezone(date, options);
// mssql not allow +timezone datetime format
return date.format('YYYY-MM-DD HH:mm:ss.SSS');
}; };
function DATEONLY() { function DATEONLY() {
......
...@@ -169,14 +169,14 @@ suite(Support.getTestDialectTeaser('SQL'), function() { ...@@ -169,14 +169,14 @@ suite(Support.getTestDialectTeaser('SQL'), function() {
suite('DATE', function () { suite('DATE', function () {
testsql('DATE', DataTypes.DATE, { testsql('DATE', DataTypes.DATE, {
postgres: 'TIMESTAMP WITH TIME ZONE', postgres: 'TIMESTAMP WITH TIME ZONE',
mssql: 'DATETIME2', mssql: 'DATETIMEOFFSET',
mysql: 'DATETIME', mysql: 'DATETIME',
sqlite: 'DATETIME' sqlite: 'DATETIME'
}); });
testsql('DATE(6)', DataTypes.DATE(6), { testsql('DATE(6)', DataTypes.DATE(6), {
postgres: 'TIMESTAMP WITH TIME ZONE', postgres: 'TIMESTAMP WITH TIME ZONE',
mssql: 'DATETIME2', mssql: 'DATETIMEOFFSET',
mysql: 'DATETIME(6)', mysql: 'DATETIME(6)',
sqlite: 'DATETIME' sqlite: 'DATETIME'
}); });
......
...@@ -54,7 +54,7 @@ describe(Support.getTestDialectTeaser('SQL'), function() { ...@@ -54,7 +54,7 @@ describe(Support.getTestDialectTeaser('SQL'), function() {
{ {
postgres: 'INSERT INTO "users" ("date") VALUES (\'2015-01-20 01:00:00.000 +01:00\');', postgres: 'INSERT INTO "users" ("date") VALUES (\'2015-01-20 01:00:00.000 +01:00\');',
sqlite: 'INSERT INTO `users` (`date`) VALUES (\'2015-01-20 00:00:00.000 +00:00\');', sqlite: 'INSERT INTO `users` (`date`) VALUES (\'2015-01-20 00:00:00.000 +00:00\');',
mssql: 'INSERT INTO [users] ([date]) VALUES (N\'2015-01-20 01:00:00.000\');', mssql: 'INSERT INTO [users] ([date]) VALUES (N\'2015-01-20 01:00:00.000 +01:00\');',
mysql: "INSERT INTO `users` (`date`) VALUES ('2015-01-20 01:00:00');" mysql: "INSERT INTO `users` (`date`) VALUES ('2015-01-20 01:00:00');"
}); });
}); });
...@@ -76,7 +76,7 @@ describe(Support.getTestDialectTeaser('SQL'), function() { ...@@ -76,7 +76,7 @@ describe(Support.getTestDialectTeaser('SQL'), function() {
{ {
postgres: 'INSERT INTO "users" ("date") VALUES (\'2015-01-20 02:02:03.089 +01:00\');', postgres: 'INSERT INTO "users" ("date") VALUES (\'2015-01-20 02:02:03.089 +01:00\');',
sqlite: 'INSERT INTO `users` (`date`) VALUES (\'2015-01-20 01:02:03.089 +00:00\');', sqlite: 'INSERT INTO `users` (`date`) VALUES (\'2015-01-20 01:02:03.089 +00:00\');',
mssql: 'INSERT INTO [users] ([date]) VALUES (N\'2015-01-20 02:02:03.089\');', mssql: 'INSERT INTO [users] ([date]) VALUES (N\'2015-01-20 02:02:03.089 +01:00\');',
mysql: "INSERT INTO `users` (`date`) VALUES ('2015-01-20 02:02:03.089');" mysql: "INSERT INTO `users` (`date`) VALUES ('2015-01-20 02:02:03.089');"
}); });
}); });
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!