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

When to use transformFixtureDataFn vs modifyFixtureDataFn #82

Open
bschlenk opened this issue Nov 7, 2017 · 1 comment
Open

When to use transformFixtureDataFn vs modifyFixtureDataFn #82

bschlenk opened this issue Nov 7, 2017 · 1 comment
Labels
question tech debt Technical debt, cleanup, other non-feature/non-bug fixes

Comments

@bschlenk
Copy link

bschlenk commented Nov 7, 2017

These two methods look like they are called one after the other, regardless of anything else:
https://github.com/domasx2/sequelize-fixtures/blob/master/lib/loader.js#L135-L143

Is there supposed to be a difference between them? Looking at the code it seems that I could choose either one and it would do the same thing. Maybe one should be deprecated since they both seem to be doing the exact same thing?

@matmar10
Copy link
Collaborator

I agree with you @bschlenk this seems like duplicated functionality. They are evaluated very close together in the code:

    // Allows an external caller to modify the data
    // before it is evaluated
    if (this.options.modifyFixtureDataFn) {
        data = this.options.modifyFixtureDataFn(data, Model);
    }

    // Allows an external caller to do some transforms to the data
    // before it is saved
    if (this.options.transformFixtureDataFn) {
        result = this.options.transformFixtureDataFn(data, Model);
    }

The modifyFixtureDataFn seems like it should come after setters, associations, and such are applied.

Removing this would probably be a breaking change but we could at least mark one of them for depreciation and start raising a warning when one is used. Thoughts?

@matmar10 matmar10 added the tech debt Technical debt, cleanup, other non-feature/non-bug fixes label Apr 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question tech debt Technical debt, cleanup, other non-feature/non-bug fixes
Projects
None yet
Development

No branches or pull requests

2 participants