Skip to content

Commit de88912

Browse files
committedNov 9, 2015
release 4.2.5
1 parent fae7c94 commit de88912

File tree

3 files changed

+36
-4
lines changed

3 files changed

+36
-4
lines changed
 

‎History.md

+16
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
4.2.5 / 2015-11-09
2+
==================
3+
* fixed; handle setting fields in pre update hooks with exec #3549
4+
* upgraded; ESLint #3547 [ChristianMurphy](https://github.com/ChristianMurphy)
5+
* fixed; bluebird unhandled rejections with cast errors and .exec #3543
6+
* fixed; min/max validators handling undefined #3539
7+
* fixed; standalone mongos connections #3537
8+
* fixed; call `.toObject()` when setting a single nested doc #3535
9+
* fixed; single nested docs now have methods #3534
10+
* fixed; single nested docs with .create() #3533 #3521 [tusbar](https://github.com/tusbar)
11+
* docs; deep populate docs #3528
12+
* fixed; deep populate schema ref handling #3507
13+
* upgraded; mongodb driver -> 2.0.48 for sort overflow issue #3493
14+
* docs; clarify default ids for discriminators #3482
15+
* fixed; properly support .update(doc) #3221
16+
117
4.2.4 / 2015-11-02
218
==================
319
* fixed; upgraded `ms` package for security vulnerability #3254 [fhemberger](https://github.com/fhemberger)

‎bin/mongoose.js

+19-3
Original file line numberDiff line numberDiff line change
@@ -956,6 +956,12 @@ Document.prototype.set = function(path, val, type, options) {
956956
this.set(path[key], prefix + key, constructing);
957957
} else if (strict) {
958958
if ('real' === pathtype || 'virtual' === pathtype) {
959+
// Check for setting single embedded schema to document (gh-3535)
960+
if (this.schema.paths[pathName] &&
961+
this.schema.paths[pathName].$isSingleNested &&
962+
path[key] instanceof Document) {
963+
path[key] = path[key].toObject({ virtuals: false });
964+
}
959965
this.set(prefix + key, path[key], constructing);
960966
} else if (pathtype === 'nested' && path[key] instanceof Document) {
961967
this.set(prefix + key,
@@ -6122,6 +6128,16 @@ function Embedded(schema, path, options) {
61226128
_embedded.$isSingleNested = true;
61236129
_embedded.prototype.$basePath = path;
61246130

6131+
// apply methods
6132+
for (var i in schema.methods) {
6133+
_embedded.prototype[i] = schema.methods[i];
6134+
}
6135+
6136+
// apply statics
6137+
for (i in schema.statics) {
6138+
_embedded[i] = schema.statics[i];
6139+
}
6140+
61256141
this.caster = _embedded;
61266142
this.schema = schema;
61276143
this.$isSingleNested = true;
@@ -6396,7 +6412,7 @@ SchemaNumber.prototype.min = function(value, message) {
63966412
msg = msg.replace(/{MIN}/, value);
63976413
this.validators.push({
63986414
validator: this.minValidator = function(v) {
6399-
return v === null || v >= value;
6415+
return v == null || v >= value;
64006416
},
64016417
message: msg,
64026418
type: 'min',
@@ -6450,7 +6466,7 @@ SchemaNumber.prototype.max = function(value, message) {
64506466
msg = msg.replace(/{MAX}/, value);
64516467
this.validators.push({
64526468
validator: this.maxValidator = function(v) {
6453-
return v === null || v <= value;
6469+
return v == null || v <= value;
64546470
},
64556471
message: msg,
64566472
type: 'max',
@@ -9639,9 +9655,9 @@ EmbeddedDocument.prototype.constructor = EmbeddedDocument;
96399655
*/
96409656

96419657
EmbeddedDocument.prototype.markModified = function(path) {
9658+
this.$__.activePaths.modify(path);
96429659
if (!this.__parentArray) return;
96439660

9644-
this.$__.activePaths.modify(path);
96459661
if (this.isNew) {
96469662
// Mark the WHOLE parent array as modified
96479663
// if this is a new document (i.e., we are initializing

‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "mongoose",
33
"description": "Mongoose MongoDB ODM",
4-
"version": "4.2.5-pre",
4+
"version": "4.2.5",
55
"author": "Guillermo Rauch <guillermo@learnboost.com>",
66
"keywords": [
77
"mongodb",

0 commit comments

Comments
 (0)
Please sign in to comment.