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