Skip to content

Commit

Permalink
save support for point types
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Romanko committed Jul 6, 2013
1 parent b78c515 commit e8342bd
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/Drivers/DML/mysql.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,8 @@ Driver.prototype.propertyToValue = function (value, property) {
return (value) ? 1 : 0;
case "object":
return JSON.stringify(value);
case "point":
return function() { return 'POINT(' + value[0] + ', ' + value[1] + ')'; };
default:
return value;
}
Expand Down
19 changes: 19 additions & 0 deletions test/integration2/model-save.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,4 +196,23 @@ describe("Model.save()", function() {
});
});
});

describe("with a point property", function () {
before(setup({type: 'point'}, null));

it("should save the instance as a geospatial point", function (done) {
var John = new Person({
name: [51.5177, -0.0968]
});
John.save(function (err) {
should.equal(err, null);

John.name.should.be.an.instanceOf(Array);
John.name.should.have.length(2);
John.name[0].should.equal(51.5177);
John.name[1].should.equal(-0.0968);
return done();
});
});
});
});

0 comments on commit e8342bd

Please sign in to comment.