Skip to content

Commit e8342bd

Browse files
author
Brian Romanko
committed
save support for point types
1 parent b78c515 commit e8342bd

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

lib/Drivers/DML/mysql.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,8 @@ Driver.prototype.propertyToValue = function (value, property) {
246246
return (value) ? 1 : 0;
247247
case "object":
248248
return JSON.stringify(value);
249+
case "point":
250+
return function() { return 'POINT(' + value[0] + ', ' + value[1] + ')'; };
249251
default:
250252
return value;
251253
}

test/integration2/model-save.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,4 +196,23 @@ describe("Model.save()", function() {
196196
});
197197
});
198198
});
199+
200+
describe("with a point property", function () {
201+
before(setup({type: 'point'}, null));
202+
203+
it("should save the instance as a geospatial point", function (done) {
204+
var John = new Person({
205+
name: [51.5177, -0.0968]
206+
});
207+
John.save(function (err) {
208+
should.equal(err, null);
209+
210+
John.name.should.be.an.instanceOf(Array);
211+
John.name.should.have.length(2);
212+
John.name[0].should.equal(51.5177);
213+
John.name[1].should.equal(-0.0968);
214+
return done();
215+
});
216+
});
217+
});
199218
});

0 commit comments

Comments
 (0)