Merge branch 'release/2.14.1' into production

This commit is contained in:
Miroslav Bajtoš 2015-01-15 08:53:59 +01:00
commit a5c8e2eb58
5 changed files with 65 additions and 22 deletions

View File

@ -1,3 +1,11 @@
2015-01-15, Version 2.14.1
==========================
* Fix detection of `util.inspect` version (Miroslav Bajtoš)
* fix recursive calls if create belongsTo model in beforeCreate hook (Clark Wang)
2015-01-14, Version 2.14.0
==========================
@ -321,16 +329,9 @@
* Emit deleted event on delete for embedsMany relations (Jaka Hudoklin)
* Make sure falsy value is kept for properties not predefined (Raymond Feng)
* Add ping() to test connections (Raymond Feng)
2014-08-21, Version 2.5.1
=========================
2014-08-21, Version 2.5.2
=========================
@ -338,6 +339,12 @@
* Make sure falsy value is kept for properties not predefined (Raymond Feng)
2014-08-21, Version 2.5.1
=========================
* Bump version (Raymond Feng)
* Fix side-effects of PR #237 - see #242 (Fabien Franzen)
@ -902,14 +909,6 @@
* JSDoc improvements (Rand McKinney)
* validations: include more details in `err.message` (Miroslav Bajtoš)
2014-05-27, Version 1.5.4
=========================
* Bump version (Raymond Feng)
* Keep undefined/null values for the array type (Raymond Feng)
* Remove JSDocs for scopeMethods.add(acInst) and scopeMethods.remove(acInst) (crandmck)
@ -945,6 +944,24 @@
* Remove remoting metadata (Ritchie Martori)
2014-05-27, Version 1.5.4
=========================
* Bump version (Raymond Feng)
* Keep undefined/null values for the array type (Raymond Feng)
* Remove JSDocs for scopeMethods.add(acInst) and scopeMethods.remove(acInst) (crandmck)
* Copy info from api-model.md to JSDoc (crandmck)
* validations: include more details in `err.message` (Miroslav Bajtoš)
* Add a path to show customer.orders(query, cb) (Raymond Feng)
* Add support for logical operator (AND/OR) (Raymond Feng)
2014-05-20, Version 1.5.2
=========================

View File

@ -441,8 +441,9 @@ ModelBaseClass.prototype.reset = function () {
// Node v0.11+ allows custom inspect functions to return an object
// instead of string. That way options like `showHidden` and `colors`
// can be preserved.
var versionParts = process.versions.node
.split(/\./g).map(function(v) { return +v; });
var versionParts = process.versions && process.versions.node ?
process.versions.node.split(/\./g).map(function(v) { return +v; }) :
[1, 0, 0]; // browserify ships 1.0-compatible version of util.inspect
var INSPECT_SUPPORTS_OBJECT_RETVAL =
versionParts[0] > 0 ||

View File

@ -1193,11 +1193,16 @@ BelongsTo.prototype.create = function(targetModelData, cb) {
modelTo.create(targetModelData, function(err, targetModel) {
if(!err) {
modelInstance[fk] = targetModel[pk];
if (modelInstance.isNewRecord()) {
self.resetCache(targetModel);
cb && cb(err, targetModel);
} else {
modelInstance.save(function(err, inst) {
if (cb && err) return cb && cb(err);
self.resetCache(targetModel);
cb && cb(err, targetModel);
});
}
} else {
cb && cb(err);
}

View File

@ -1,6 +1,6 @@
{
"name": "loopback-datasource-juggler",
"version": "2.14.0",
"version": "2.14.1",
"description": "LoopBack DataSoure Juggler",
"keywords": [
"StrongLoop",

View File

@ -1657,6 +1657,23 @@ describe('relations', function () {
});
});
it('should allow to create belongsTo model in beforeCreate hook', function (done) {
var mind;
Fear.beforeCreate = function (next) {
this.mind.create(function (err, m) {
mind = m;
if (err) next(err); else next();
});
};
Fear.create(function (err, fear) {
should.not.exists(err);
should.exists(fear);
fear.mindId.should.be.equal(mind.id);
should.exists(fear.mind());
done();
});
});
});
describe('belongsTo with scope', function () {
@ -1680,9 +1697,12 @@ describe('relations', function () {
p.personId.should.equal(person.id);
person.name.should.equal('Fred');
person.passportNotes.should.equal('Some notes...');
p.save(function (err, passport) {
should.not.exists(err);
done();
});
});
});
it('should find record on scope', function (done) {
Passport.findOne(function (err, p) {