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

Commit cbefbbca by Sushant

Fix(#4953) : Added failing test

1 parent 48f26b33
# Future
- [FIXED] MySQL throws error when null GEOMETRY data results in empty buffer [#4953](https://github.com/sequelize/sequelize/issues/4953)
# 3.16.0 # 3.16.0
- [ADDED] PostgreSQL tsrange (Range of timestamp without time zone) data type support. - [ADDED] PostgreSQL tsrange (Range of timestamp without time zone) data type support.
- [ADDED] hasOne scope support [#5113](https://github.com/sequelize/sequelize/pull/5113) - [ADDED] hasOne scope support [#5113](https://github.com/sequelize/sequelize/pull/5113)
- [FIXED] attributes from multiple scopes does not merge [#4856](https://github.com/sequelize/sequelize/issues/4856) - [FIXED] attributes from multiple scopes does not merge [#4856](https://github.com/sequelize/sequelize/issues/4856)
- [FIXED] Support Unicode strings in mssql [#3752](https://github.com/sequelize/sequelize/issues/3752) - [FIXED] Support Unicode strings in mssql [#3752](https://github.com/sequelize/sequelize/issues/3752)
- [FIXED] Do not inject include twice in `options.include` [#5106](https://github.com/sequelize/sequelize/pull/5106) - [FIXED] Do not inject include twice in `options.include` [#5106](https://github.com/sequelize/sequelize/pull/5106)
- [FIXED] Expand and validate include in `aggregate` [#5106](https://github.com/sequelize/sequelize/pull/5106) - [FIXED] Expand and validate include in `aggregate`
# 3.15.1 # 3.15.1
- [FIXED] calling Model.update() modifies passed values [#4520](https://github.com/sequelize/sequelize/issues/4520) - [FIXED] calling Model.update() modifies passed values [#4520](https://github.com/sequelize/sequelize/issues/4520)
......
...@@ -60,8 +60,13 @@ module.exports = function (BaseTypes) { ...@@ -60,8 +60,13 @@ module.exports = function (BaseTypes) {
}); });
GEOMETRY.parse = GEOMETRY.prototype.parse = function(value) { GEOMETRY.parse = GEOMETRY.prototype.parse = function(value) {
value = value.buffer();
if (value === null) {
return null;
}
// For some reason, discard the first 4 bytes // For some reason, discard the first 4 bytes
value = value.buffer().slice(4); value = value.slice(4);
return wkx.Geometry.parse(value).toGeoJSON(); return wkx.Geometry.parse(value).toGeoJSON();
}; };
......
...@@ -273,4 +273,28 @@ describe(Support.getTestDialectTeaser('DataTypes'), function() { ...@@ -273,4 +273,28 @@ describe(Support.getTestDialectTeaser('DataTypes'), function() {
// No dialects actually allow us to identify that we get an enum back.. // No dialects actually allow us to identify that we get an enum back..
testFailure(Type); testFailure(Type);
}); });
it('should parse an empty GEOMETRY field', function () {
var Type = new Sequelize.GEOMETRY();
if (current.dialect.supports.GEOMETRY) {
current.refreshTypes();
var User = current.define('user', { field: Type }, { timestamps: false });
var point = { type: "Point", coordinates: [] };
return current.sync({ force: true }).then(function () {
return User.create({
//insert a null GEOMETRY type
field: point
});
}).then(function () {
//This case throw unhandled exception
return User.findAll();
}).then(function(users){
//it contains the null GEOMETRY data
expect(users[0].field).to.be.null;
});
}
});
}); });
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!