-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use proper $and in patch and remove methods #383
Comments
Also, we likely need to do some more type checking on the feathers-sequelize/lib/index.js Line 169 in db4b5ff
So if $and works with an object and not just an array, when we need to check that. I think it is most common that its an array so we should also return an array.
Something like applyAndQuery(where, id) {
const { and } = this.Op;
const IdQuery = { [this.id]: id };
const newWhere = Object.assign({}, where);
if (!newWhere[and]) {
newWhere[and] = [IdQuery]
return newWhere;
}
if (Array.isArray(newWhere[and])) {
newWhere[and] = [...newWhere[and], idQuery];
return newWhere;
}
newWhere[and] = [newWhere[and], idQuery];
return newWhere;
} |
Good catch! We should add a test for that. Maybe even on
where: {
rank: {
[Op.and]: {
[Op.lt]: 1000,
[Op.eq]: null
}
},
} |
resolved by #429 |
@fratzinger Made an excellent PR recently that ensures the user's
$and
query is not overwritten. See 8de0144We should similarly update the
_patch
and_remove
methods to do so. Note that this issue should probably be accomplished first: #382. Right now the_patch
does not use and$and
query, but if we update it to work more similarly to_remove
then it will use an$and
query I believe.The text was updated successfully, but these errors were encountered: