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

Commit 6931c795 by Sushant Committed by GitHub

fix: regression in mysql2, handle null buffer (#8678)

1 parent 24b37364
......@@ -150,7 +150,7 @@ module.exports = BaseTypes => {
// Empty buffer, MySQL doesn't support POINT EMPTY
// check, https://dev.mysql.com/worklog/task/?id=2381
if (value.length === 0) {
if (!value || value.length === 0) {
return null;
}
......
......@@ -73,7 +73,7 @@
"istanbul": "^0.4.5",
"lcov-result-merger": "^1.2.0",
"mocha": "^3.0.2",
"mysql2": "^1.5.0",
"mysql2": "^1.5.1",
"pg": "^6.1.0",
"pg-hstore": "^2.3.2",
"pg-native": "^1.10.0",
......
......@@ -307,7 +307,7 @@ describe(Support.getTestDialectTeaser('DataTypes'), () => {
return current.sync({ force: true }).then(() => {
return User.create({
//insert a null GEOMETRY type
//insert a empty GEOMETRY type
field: point
});
}).then(() => {
......@@ -327,6 +327,27 @@ describe(Support.getTestDialectTeaser('DataTypes'), () => {
}
});
});
it('should parse null GEOMETRY field', () => {
const Type = new Sequelize.GEOMETRY();
current.refreshTypes();
const User = current.define('user', { field: Type }, { timestamps: false });
const point = null;
return current.sync({ force: true }).then(() => {
return User.create({
// insert a null GEOMETRY type
field: point
});
}).then(() => {
//This case throw unhandled exception
return User.findAll();
}).then(users =>{
expect(users[0].field).to.be.eql(null);
});
});
}
if (dialect === 'postgres' || dialect === 'sqlite') {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!