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
{{ message }}
This repository has been archived by the owner on Sep 6, 2023. It is now read-only.
./services/filter-query.js, ./controllers/model.js, and ./services/endpoint.js use Knex's modify function incorrectly. See the documentation.
Instead of returning functions (in filter-query.js) and binding parameters (in endpoint.js), just call modify with a function as its first parameter, and the other parameters will be passed to the function.
The text was updated successfully, but these errors were encountered:
This is easy to fix in services/filter-query.js, but difficult to fix in all of the individual controllers that supply knex.modify() functions.
The reason it is difficult is because the flow looks like this:
controller declares a modify function ((req, queryBuilder) => { ... })
controller passes modify function to endpoint service
endpoint service binds req as the first parameter to the modify function
endpoint service passes the modify function to the db service
db service calls modify function like knex.modify(modifyFunction), expecting the function to accept queryBuilder as its first parameter (which it does, after req is bound in the endpoint service)
The fix would look like:
changing the parameters of each modify function to queryBuilder, req
not binding the modify function in the endpoint service
passing req into the db service so it could call the modify function like knex.modify(modifyFunction, req)
The problem with this is that it increases the coupling between the endpoint service and the db service, a problem that will be solved in #373 Refactor endpoint service. Once the endpoint service is refactored to not pass parameters through to the db service, each controller can directly pass req to the db service so that modify() can be used correctly.
./services/filter-query.js
,./controllers/model.js
, and./services/endpoint.js
use Knex's modify function incorrectly. See the documentation.Instead of returning functions (in
filter-query.js
) and binding parameters (inendpoint.js
), just callmodify
with a function as its first parameter, and the other parameters will be passed to the function.The text was updated successfully, but these errors were encountered: