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

Commit 351e871b by Sushant Committed by Sushant

Fix(#4953) : Return null until MySQL implements EMPTY keyword for WKT

1 parent cbefbbca
...@@ -398,13 +398,13 @@ AbstractQuery.formatBindParameters = function(sql, values, dialect, replacementF ...@@ -398,13 +398,13 @@ AbstractQuery.formatBindParameters = function(sql, values, dialect, replacementF
if (!values) { if (!values) {
return [sql, []]; return [sql, []];
} }
options = options || {}; options = options || {};
if (typeof replacementFunc !== 'function') { if (typeof replacementFunc !== 'function') {
options = replacementFunc || {}; options = replacementFunc || {};
replacementFunc = undefined; replacementFunc = undefined;
} }
if (!replacementFunc) { if (!replacementFunc) {
if (options.skipValueReplace) { if (options.skipValueReplace) {
replacementFunc = function(match, key, values, timeZone, dialect, options) { replacementFunc = function(match, key, values, timeZone, dialect, options) {
...@@ -432,15 +432,15 @@ AbstractQuery.formatBindParameters = function(sql, values, dialect, replacementF ...@@ -432,15 +432,15 @@ AbstractQuery.formatBindParameters = function(sql, values, dialect, replacementF
}; };
} }
} }
var timeZone = null; var timeZone = null;
var list = Array.isArray(values); var list = Array.isArray(values);
sql = sql.replace(/\$(\$|\w+)/g, function(match, key) { sql = sql.replace(/\$(\$|\w+)/g, function(match, key) {
if ('$' === key) { if ('$' === key) {
return options.skipUnescape ? match : key; return options.skipUnescape ? match : key;
} }
var replVal; var replVal;
if (list) { if (list) {
if (key.match(/^[1-9]\d*$/)) { if (key.match(/^[1-9]\d*$/)) {
......
...@@ -61,8 +61,10 @@ module.exports = function (BaseTypes) { ...@@ -61,8 +61,10 @@ module.exports = function (BaseTypes) {
GEOMETRY.parse = GEOMETRY.prototype.parse = function(value) { GEOMETRY.parse = GEOMETRY.prototype.parse = function(value) {
value = value.buffer(); value = value.buffer();
if (value === null) {
return null; //MySQL doesn't support POINT EMPTY, https://dev.mysql.com/worklog/task/?id=2381
if(value === null){
return null;
} }
// For some reason, discard the first 4 bytes // For some reason, discard the first 4 bytes
......
...@@ -292,8 +292,13 @@ describe(Support.getTestDialectTeaser('DataTypes'), function() { ...@@ -292,8 +292,13 @@ describe(Support.getTestDialectTeaser('DataTypes'), function() {
//This case throw unhandled exception //This case throw unhandled exception
return User.findAll(); return User.findAll();
}).then(function(users){ }).then(function(users){
//it contains the null GEOMETRY data if (dialect === 'mysql') {
expect(users[0].field).to.be.null; // MySQL will return NULL, becuase they lack EMPTY geometry data support.
expect(users[0].field).to.be.eql(null);
} else {
//it contains the null GEOMETRY data
expect(users[0].field).to.be.deep.eql(point);
}
}); });
} }
}); });
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!