* Test for JSON object or any type * dao.js coercion type.definition existence check
This commit is contained in:
parent
29676f6510
commit
88771f10fc
|
@ -1610,9 +1610,12 @@ DataAccessObject._coerce = function(where, props) {
|
|||
if (props[model]) {
|
||||
var clause = {};
|
||||
clause[prop] = where[p];
|
||||
where[p] = Array.isArray(props[model].type) ?
|
||||
self._coerce(clause, props[model].type[0].definition.properties)[prop] :
|
||||
self._coerce(clause, props[model].type.definition.properties)[prop];
|
||||
var type = Array.isArray(props[model].type) ? props[model].type[0] : props[model].type;
|
||||
if (type && type.definition && type.definition.properties) {
|
||||
where[p] = self._coerce(clause, type.definition.properties)[prop];
|
||||
continue;
|
||||
}
|
||||
// else fall-back to old/default coercion
|
||||
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ describe('crud-with-options', function() {
|
|||
role: {type: String, index: true},
|
||||
order: {type: Number, index: true, sort: true},
|
||||
vip: {type: Boolean},
|
||||
meta: {type: Object},
|
||||
});
|
||||
options = {};
|
||||
filter = {fields: ['name', 'id']};
|
||||
|
@ -259,6 +260,15 @@ describe('crud-with-options', function() {
|
|||
});
|
||||
});
|
||||
|
||||
it('should not throw for nested properties for ANY or Object type', function(done) {
|
||||
User.find({where: {'meta.thisPropertyNotDefined': true}}, function(err, users) {
|
||||
should.not.exists(err);
|
||||
should.exists(users);
|
||||
users.should.have.lengthOf(0);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should allow find(filter, options)', function() {
|
||||
User.find({limit: 3}, options);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue