Commit 6940e7a7ef7085fb81ebd16a0619b8af86113c29

Authored by Arek W
1 parent 6910216b

Add default returned test #485

test/integration/model-create.js
... ... @@ -6,6 +6,7 @@ describe("Model.create()", function() {
6 6 var db = null;
7 7 var Pet = null;
8 8 var Person = null;
  9 + var Pen = null;
9 10  
10 11 var setup = function () {
11 12 return function (done) {
... ... @@ -18,7 +19,11 @@ describe("Model.create()", function() {
18 19 });
19 20 Person.hasMany("pets", Pet);
20 21  
21   - return helper.dropSync([ Person, Pet ], done);
  22 + Pen = db.define("pen", {
  23 + colour : { type: "text" }
  24 + });
  25 +
  26 + return helper.dropSync([ Person, Pet, Pen ], done);
22 27 };
23 28 };
24 29  
... ... @@ -148,5 +153,22 @@ describe("Model.create()", function() {
148 153 });
149 154 })
150 155 });
  156 +
  157 + it("should return the default value set in the databse", function (done) {
  158 + db.driver.execQuery(
  159 + "ALTER TABLE ?? ALTER COLUMN ?? SET DEFAULT ?", [Pen.table, 'colour', 'blue'],
  160 + function (err) {
  161 + should.not.exist(err);
  162 +
  163 + Pen.create({colour: undefined}, function (err, pen) {
  164 + should.not.exist(err);
  165 +
  166 + should.equal(pen.colour, 'blue');
  167 +
  168 + done();
  169 + });
  170 + }
  171 + );
  172 + });
151 173 });
152 174 });
... ...