strapi icon indicating copy to clipboard operation
strapi copied to clipboard

filter and where for findOne, update, delete

Open akaJes opened this issue 1 year ago • 1 comments

Bug report

Required System information

  • Node.js version: v16.15.1
  • NPM version: 8.11.0
  • Strapi version: 4.2.2
  • Database: mysqld Ver 5.7.33-0ubuntu0.16.04.1 for Linux on x86_64 ((Ubuntu))
  • Operating system: ubuntu

Describe the bug

overriding user filter for findOne update delete https://github.com/strapi/strapi/blob/master/packages/core/strapi/lib/services/entity-service/index.js#L146 https://github.com/strapi/strapi/blob/master/packages/core/strapi/lib/services/entity-service/index.js#L197 https://github.com/strapi/strapi/blob/master/packages/core/strapi/lib/services/entity-service/index.js#L245

const query = transformParamsToQuery(uid, pickSelectionParams(wrappedParams));
return db.query(uid).findOne({ ...query, where: { id: entityId } });

code like above reset user filter state - where is overrided

Expected behavior

parsed from query filters must be concatenated with where parameter somthing like:

query.where = query.where || {}
query.where.id = entityId

akaJes avatar Jul 05 '22 14:07 akaJes

Upgrading to medium as this is becoming fairly popular on Discord.

derrickmehaffy avatar Jul 14 '22 21:07 derrickmehaffy

Hi, If the issue is still open, I want to work on it. :)

vikasvmads avatar Sep 05 '22 04:09 vikasvmads