Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge

  • Loading branch information...
commit 43d1cbd39e699089bece1e1545c2ec9d1ee566f3 1 parent fe4f722
@1602 authored
Showing with 56 additions and 1 deletion.
  1. +1 −1  lib/model.js
  2. +55 −0 test/schema.test.js
View
2  lib/model.js
@@ -560,7 +560,7 @@ AbstractClass.include = function (objects, include, cb) {
var inValues = [];
for (var j = 0; j < keyVals[relation.keyFrom].length; j++) {
keysToBeProcessed[keyVals[relation.keyFrom][j]] = true;
- if (keyVals[relation.keyFrom][j] !== 'null') {
+ if (keyVals[relation.keyFrom][j] !== 'null' && keyVals[relation.keyFrom][j] !== 'undefined') {
inValues.push(keyVals[relation.keyFrom][j]);
}
}
View
55 test/schema.test.js
@@ -0,0 +1,55 @@
+var db = getSchema(), slave = getSchema(), Model, SlaveModel;
+var should = require('should');
+
+describe.skip('schema', function() {
+
+ it('should define Model', function() {
+ Model = db.define('Model');
+ Model.schema.should.eql(db);
+ var m = new Model;
+ m.schema.should.eql(db);
+ });
+
+ it('should clone existing model', function() {
+ SlaveModel = slave.copyModel(Model);
+ SlaveModel.schema.should.eql(slave);
+ slave.should.not.eql(db);
+ var sm = new SlaveModel;
+ sm.should.be.instanceOf(Model);
+ sm.schema.should.not.eql(db);
+ sm.schema.should.eql(slave);
+ });
+
+ it('should automigrate', function(done) {
+ db.automigrate(done);
+ });
+
+ it('should create transaction', function(done) {
+ var tr = db.transaction();
+ tr.connected.should.be.false;
+ tr.connecting.should.be.false;
+ var called = false;
+ tr.models.Model.create(Array(3), function () {
+ called = true;
+ });
+ tr.connected.should.be.false;
+ tr.connecting.should.be.true;
+
+ db.models.Model.count(function(err, c) {
+ should.not.exist(err);
+ should.exist(c);
+ c.should.equal(0);
+ called.should.be.false;
+ tr.exec(function () {
+ setTimeout(function() {
+ called.should.be.true;
+ db.models.Model.count(function(err, c) {
+ c.should.equal(3);
+ done();
+ });
+ }, 100);
+ });
+ });
+ });
+
+});
Please sign in to comment.
Something went wrong with that request. Please try again.