You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@fratzinger Made an excellent PR recently that ensures the user's $and query is not overwritten. See 8de0144
We 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.
Also, we likely need to do some more type checking on the $and. Note in this line that we assume the $and is an array. But the code also potentially returns an object instead of an array.
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;constIdQuery={[this.id]: id};constnewWhere=Object.assign({},where);if(!newWhere[and]){newWhere[and]=[IdQuery]returnnewWhere;}if(Array.isArray(newWhere[and])){newWhere[and]=[...newWhere[and],idQuery];returnnewWhere;}newWhere[and]=[newWhere[and],idQuery];returnnewWhere;}
Activity
DaddyWarbucks commentedon Jan 9, 2022
Also, we likely need to do some more type checking on the
$and. Note in this line that we assume the$andis an array. But the code also potentially returns an object instead of an array.feathers-sequelize/lib/index.js
Line 169 in db4b5ff
So if
$andworks 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
fratzinger commentedon Jan 9, 2022
Good catch! We should add a test for that. Maybe even on
@feathersjs/adapter-testsand we could add$andto the official supported operators list at https://docs.feathersjs.com/api/databases/querying.html.Op.andandOp.orcan be used as an object, indeed (see https://sequelize.org/v6/manual/model-querying-basics.html#examples-with--code-op-and--code--and--code-op-or--code-). But I believe at the root level they're always meant to be arrays. It makes sense if they're nested within a column query like:fratzinger commentedon May 12, 2024
resolved by #429