Skip to content

Service call sometimes returns data from wrong table when called internally #117

Open
@RobIsHere

Description

@RobIsHere

Steps to reproduce

  • create a knex db service
  • add a find before hook that uses hook.params.knex with any custom query:
hook => {
    hook.params.knex = hook.service.createQuery(hook.params.query);
}
  • at find after hook add a populate common hook including something from other service

Expected behavior

  • it should find the data from other service and include it

Actual behavior

  • it includes the record in this service again in itself

System configuration

Newest versions of feathers

Reason

https://github.com/feathersjs/feathers-knex/blob/master/src/index.js#L132
var q = params.knex || this.createQuery(params);

this reuses a previously executed query, although it has been set in the "parent" service fetching the parent record. As params.knex is already set, the params of the called "child" service are ignored and the parent query is run again.

How to solve this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions