diff --git a/History.md b/History.md index 76f4edb6fec..340c3db2162 100644 --- a/History.md +++ b/History.md @@ -1,4 +1,14 @@ +1.1.15 / 2011-03-28 +=================== + + * Fixed; `null` and `undefined` are set atomically. + +1.1.14 / 2011-03-28 +=================== + + * Changed; more forgiving date casting, accepting '' as null. + 1.1.13 / 2011-03-26 =================== diff --git a/lib/mongoose/index.js b/lib/mongoose/index.js index edfd08f2916..9631e3868fc 100644 --- a/lib/mongoose/index.js +++ b/lib/mongoose/index.js @@ -281,7 +281,7 @@ exports.Connection = Connection; * @param version */ -exports.version = '1.1.13'; +exports.version = '1.1.15'; /** * Export Mongoose constructor diff --git a/lib/mongoose/model.js b/lib/mongoose/model.js index 373c93cdac5..2bcf3e42394 100644 --- a/lib/mongoose/model.js +++ b/lib/mongoose/model.js @@ -104,7 +104,10 @@ Model.prototype.save = function (fn) { , atomics, val, obj; if (type === null || type === undefined) { - delta[data.path] = type; + if (!('$set' in delta)) + delta['$set'] = {}; + + delta['$set'][data.path] = type; } else if (type._path && type.doAtomics) { // a MongooseArray or MongooseNumber atomics = type._atomics; diff --git a/lib/mongoose/schema/date.js b/lib/mongoose/schema/date.js index 92c8975646f..24ed27d912d 100644 --- a/lib/mongoose/schema/date.js +++ b/lib/mongoose/schema/date.js @@ -42,7 +42,9 @@ SchemaDate.prototype.checkRequired = function (value) { */ SchemaDate.prototype.cast = function (value) { - if (value === null) return value; + if (value === null || value === '') + return null; + if (value instanceof Date) return value; @@ -63,6 +65,12 @@ SchemaDate.prototype.cast = function (value) { throw new CastError('date', value); }; +/** + * Date Query casting. + * + * @api private + */ + function handleSingle (val) { return this.cast(val); } @@ -83,6 +91,7 @@ SchemaDate.prototype.$conditionalHandlers = { , '$in': handleArray , '$nin': handleArray }; + SchemaDate.prototype.castForQuery = function ($conditional, val) { var handler; if (arguments.length === 2) { diff --git a/package.json b/package.json index 1c687ef586b..7ee595c255d 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "mongoose" , "description": "Mongoose MongoDB ORM" - , "version": "1.1.13" + , "version": "1.1.15" , "author": "Guillermo Rauch " , "keywords": ["mongodb", "mongoose", "orm", "data", "datastore", "nosql"] , "dependencies": {} diff --git a/test/model.test.js b/test/model.test.js index ad5b8aa715c..5544f54ef90 100644 --- a/test/model.test.js +++ b/test/model.test.js @@ -2744,7 +2744,6 @@ module.exports = { (+post.get('meta').visitors).should.eql(4815162342); db.close(); - } };