Skip to content

Commit

Permalink
release 4.2.5
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 committed Nov 9, 2015
1 parent fae7c94 commit de88912
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 4 deletions.
16 changes: 16 additions & 0 deletions History.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
4.2.5 / 2015-11-09
==================
* fixed; handle setting fields in pre update hooks with exec #3549
* upgraded; ESLint #3547 [ChristianMurphy](https://github.com/ChristianMurphy)
* fixed; bluebird unhandled rejections with cast errors and .exec #3543
* fixed; min/max validators handling undefined #3539
* fixed; standalone mongos connections #3537
* fixed; call `.toObject()` when setting a single nested doc #3535
* fixed; single nested docs now have methods #3534
* fixed; single nested docs with .create() #3533 #3521 [tusbar](https://github.com/tusbar)
* docs; deep populate docs #3528
* fixed; deep populate schema ref handling #3507
* upgraded; mongodb driver -> 2.0.48 for sort overflow issue #3493
* docs; clarify default ids for discriminators #3482
* fixed; properly support .update(doc) #3221

4.2.4 / 2015-11-02
==================
* fixed; upgraded `ms` package for security vulnerability #3254 [fhemberger](https://github.com/fhemberger)
Expand Down
22 changes: 19 additions & 3 deletions bin/mongoose.js
Original file line number Diff line number Diff line change
Expand Up @@ -956,6 +956,12 @@ Document.prototype.set = function(path, val, type, options) {
this.set(path[key], prefix + key, constructing);
} else if (strict) {
if ('real' === pathtype || 'virtual' === pathtype) {
// Check for setting single embedded schema to document (gh-3535)
if (this.schema.paths[pathName] &&
this.schema.paths[pathName].$isSingleNested &&
path[key] instanceof Document) {
path[key] = path[key].toObject({ virtuals: false });
}
this.set(prefix + key, path[key], constructing);
} else if (pathtype === 'nested' && path[key] instanceof Document) {
this.set(prefix + key,
Expand Down Expand Up @@ -6122,6 +6128,16 @@ function Embedded(schema, path, options) {
_embedded.$isSingleNested = true;
_embedded.prototype.$basePath = path;

// apply methods
for (var i in schema.methods) {
_embedded.prototype[i] = schema.methods[i];
}

// apply statics
for (i in schema.statics) {
_embedded[i] = schema.statics[i];
}

this.caster = _embedded;
this.schema = schema;
this.$isSingleNested = true;
Expand Down Expand Up @@ -6396,7 +6412,7 @@ SchemaNumber.prototype.min = function(value, message) {
msg = msg.replace(/{MIN}/, value);
this.validators.push({
validator: this.minValidator = function(v) {
return v === null || v >= value;
return v == null || v >= value;
},
message: msg,
type: 'min',
Expand Down Expand Up @@ -6450,7 +6466,7 @@ SchemaNumber.prototype.max = function(value, message) {
msg = msg.replace(/{MAX}/, value);
this.validators.push({
validator: this.maxValidator = function(v) {
return v === null || v <= value;
return v == null || v <= value;
},
message: msg,
type: 'max',
Expand Down Expand Up @@ -9639,9 +9655,9 @@ EmbeddedDocument.prototype.constructor = EmbeddedDocument;
*/

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

this.$__.activePaths.modify(path);
if (this.isNew) {
// Mark the WHOLE parent array as modified
// if this is a new document (i.e., we are initializing
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "mongoose",
"description": "Mongoose MongoDB ODM",
"version": "4.2.5-pre",
"version": "4.2.5",
"author": "Guillermo Rauch <guillermo@learnboost.com>",
"keywords": [
"mongodb",
Expand Down

0 comments on commit de88912

Please sign in to comment.