diff --git a/lib/protocol/SqlString.js b/lib/protocol/SqlString.js index c9883daa3..ba63a1dbb 100644 --- a/lib/protocol/SqlString.js +++ b/lib/protocol/SqlString.js @@ -36,6 +36,10 @@ SqlString.escape = function(val, stringifyObjects, timeZone) { } if (typeof val === 'object') { + // for the mysql point class + if(val.hasOwnProperty('x') && val.hasOwnProperty('y')) { + return 'POINT(' + [val.x, val.y].map(parseFloat).join(',') + ')'; + } if (stringifyObjects) { val = val.toString(); } else { diff --git a/test/unit/protocol/test-SqlString.js b/test/unit/protocol/test-SqlString.js index dffede32f..9e6973dcd 100644 --- a/test/unit/protocol/test-SqlString.js +++ b/test/unit/protocol/test-SqlString.js @@ -117,7 +117,13 @@ test('SqlString.escape', { assert.strictEqual(string, "'" + expected + "'"); }, - + 'points are converted to POINT objects': function() { + var expected = 'POINT(123.004, -10.1)'; + var input = {x: 123.004, y: -10.1}; + var string = SqlString.escape(input); + + assert.strictEqual(string, expected); + }, 'buffers are converted to hex': function() { var buffer = new Buffer([0, 1, 254, 255]); var string = SqlString.escape(buffer);