Skip to content
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

Fixed issue where params are ignored on update service calls. #252

Conversation

AndrewJDR
Copy link
Contributor

This is another attempt at a resolution for issue #234. I will paste the content of the issue report below:

Take a look at these two lines:
/~https://github.com/feathersjs-ecosystem/feathers-sequelize/blob/master/lib/index.js#L245
/~https://github.com/feathersjs-ecosystem/feathers-sequelize/blob/master/lib/index.js#L259

Lines like these do overrides such as raw: false, which is totally fine, but in the process they also fail to pass through the other attributes of the params object that was provided by the original caller of the service method (further up the callstack).

When a service call is made by some featherjs user's code, it's important to preserve the params object when making any subsequent service calls, as it's possible that the user of feathersjs intends to use these parameters as part of a getModel() override function in a custom service class (i.e. class MySpecialService extends Service with an overidden getModel()) For things like multi-tenancy schemes (hosting multiple domains/sites out of a single app instance such that each site needs to hit a different database).

Any practice of ignoring/clobbering the params passed in will cause problems for such a scheme.

For the most part I have not noticed an issue with this -- As far as I know, get, find, and most other service calls do not have this practice of completely overriding the params with their own value, but update does have this issue. I will submit a pull request for this.

@AndrewJDR AndrewJDR force-pushed the fix_for_params_clobbering_in_update_v2 branch from fda09fa to 7f44f75 Compare December 20, 2018 10:34
@AndrewJDR AndrewJDR force-pushed the fix_for_params_clobbering_in_update_v2 branch from 7f44f75 to cabf55a Compare December 20, 2018 11:16
@daffl
Copy link
Member

daffl commented Dec 20, 2018

Thank you! Will go out with the next release

@daffl daffl merged commit aa96956 into feathersjs-ecosystem:master Dec 20, 2018
AndrewJDR added a commit to AndrewJDR/feathers-sequelize that referenced this pull request Dec 21, 2018
This is a test to further address issue feathersjs-ecosystem#234.

While PR feathersjs-ecosystem#252 did fix some of the issues, some attributes are still
not being passed through to some of the service calls as these tests
failures will indicate. Proposed fixes for these new test failures will
be forthcoming.
AndrewJDR added a commit to AndrewJDR/feathers-sequelize that referenced this pull request Dec 21, 2018
This is a test to further address issue feathersjs-ecosystem#234.

While PR feathersjs-ecosystem#252 did fix some of the issues, some attributes are still
not being passed through to some of the service calls as these tests
failures will indicate. Proposed fixes for these new test failures will
be forthcoming.
AndrewJDR added a commit to AndrewJDR/feathers-sequelize that referenced this pull request Dec 22, 2018
This is a test to further address issue feathersjs-ecosystem#234.

While PR feathersjs-ecosystem#252 did fix some of the issues, some attributes are still
not being passed through to some of the service calls as these tests
failures will indicate. Proposed fixes for these new test failures will
be forthcoming.
daffl pushed a commit that referenced this pull request Dec 26, 2018
* Added tests for custom attributes for custom getModel().

This is a test to further address issue #234.

While PR #252 did fix some of the issues, some attributes are still
not being passed through to some of the service calls as these tests
failures will indicate. Proposed fixes for these new test failures will
be forthcoming.

* Fix some getModel() / parameter passing related test failures.

This is a continuation of the work to fix issue #234.
Some service calls were still failing to pass through params.sequelize,
which again could cause issues for users that are extending
the Service class with their own getModel() method that
depends upon certain parameters being passed through to it.

* Fix remaining failing tests and introduce more getModel checks.

The getModel parameter passing tests now also check that the custom
getModel method has been called by the service methods. This will
help protect against potential future regressions that somehow fail
to call getModel().

* Run lint, make some variable names friendlier.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants