Disallow regexp string in arrays for coerce (#1279)
Disallow regexp arrays for coerce
This commit is contained in:
parent
c99441247c
commit
68b93e1074
|
@ -1737,7 +1737,9 @@ DataAccessObject._coerce = function(where, options) {
|
||||||
if (Array.isArray(val)) {
|
if (Array.isArray(val)) {
|
||||||
for (var i = 0; i < val.length; i++) {
|
for (var i = 0; i < val.length; i++) {
|
||||||
if (val[i] !== null && val[i] !== undefined) {
|
if (val[i] !== null && val[i] !== undefined) {
|
||||||
val[i] = DataType(val[i]);
|
if (!(val[i] instanceof RegExp)) {
|
||||||
|
val[i] = DataType(val[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1308,6 +1308,7 @@ describe('DataAccessObject', function() {
|
||||||
model = ds.createModel('M1', {
|
model = ds.createModel('M1', {
|
||||||
id: {type: String, id: true},
|
id: {type: String, id: true},
|
||||||
age: Number,
|
age: Number,
|
||||||
|
string: 'string',
|
||||||
vip: Boolean,
|
vip: Boolean,
|
||||||
date: Date,
|
date: Date,
|
||||||
location: 'GeoPoint',
|
location: 'GeoPoint',
|
||||||
|
@ -1653,6 +1654,12 @@ describe('DataAccessObject', function() {
|
||||||
assert.deepEqual(where, {age: {inq: ['xyz', 12]}});
|
assert.deepEqual(where, {age: {inq: ['xyz', 12]}});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('does not coerce to a string for a regexp value in an array ',
|
||||||
|
function() {
|
||||||
|
where = model._coerce({string: {inq: [/xyz/i, new RegExp(/xyz/i)]}});
|
||||||
|
assert.deepEqual(where, {string: {inq: [/xyz/i, /xyz/i]}});
|
||||||
|
});
|
||||||
|
|
||||||
// settings
|
// settings
|
||||||
it('gets settings in priority',
|
it('gets settings in priority',
|
||||||
function() {
|
function() {
|
||||||
|
|
Loading…
Reference in New Issue