Fix the regexp value for like/nlike
This commit is contained in:
parent
62a429b2a6
commit
4206088fbc
|
@ -1183,7 +1183,10 @@ DataAccessObject._coerce = function (where) {
|
|||
}
|
||||
} else {
|
||||
if (val != null) {
|
||||
val = DataType(val);
|
||||
if (!((operator === 'like' || operator === 'nlike') &&
|
||||
val instanceof RegExp)) {
|
||||
val = DataType(val);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Rebuild {property: {operator: value}}
|
||||
|
|
|
@ -164,6 +164,14 @@ describe('Memory connector', function() {
|
|||
});
|
||||
});
|
||||
|
||||
it('should allow to find using like with regexp', function(done) {
|
||||
User.find({where: {name: {like: /.*St.*/}}}, function(err, posts) {
|
||||
should.not.exist(err);
|
||||
posts.should.have.property('length', 2);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should support like for no match', function(done) {
|
||||
User.find({where: {name: {like: 'M%XY'}}}, function(err, posts) {
|
||||
should.not.exist(err);
|
||||
|
@ -180,6 +188,14 @@ describe('Memory connector', function() {
|
|||
});
|
||||
});
|
||||
|
||||
it('should allow to find using nlike with regexp', function(done) {
|
||||
User.find({where: {name: {nlike: /.*St.*/}}}, function(err, posts) {
|
||||
should.not.exist(err);
|
||||
posts.should.have.property('length', 4);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should support nlike for no match', function(done) {
|
||||
User.find({where: {name: {nlike: 'M%XY'}}}, function(err, posts) {
|
||||
should.not.exist(err);
|
||||
|
|
Loading…
Reference in New Issue