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

Can private methods be used without sanitizeParams? #155

Open
HighSoftWare96 opened this issue Jan 29, 2020 · 11 comments
Open

Can private methods be used without sanitizeParams? #155

HighSoftWare96 opened this issue Jan 29, 2020 · 11 comments

Comments

@HighSoftWare96
Copy link
Contributor

Hi,
I've noticed that private methods like _find or _create are documented in the wiki. I personally have used them in my project for overriding the default actions of the Db Adapter adding or removing something in the endpoint but at the end using the relative private method to accomplish the main goal of the action.
Something like this:

// ...
actions: {
   find: {
    params: // ...
    handler(ctx): {
       // do something more ...
       return this._find(ctx, params).then(
           // do something else
       )
    }
   },
}

The problem is that sometimes the params for the private method are not quite correct and calling the private method without calling sanitizeParams can bring to unexpected results.. I was wondering: may be the case to move the sanitizeParams inside the private method so when I try to override some default action I can be sure that the params are correctly parsed?

@icebob
Copy link
Member

icebob commented Jan 30, 2020

Hm, I don't know right now. I have to think it over.

@HighSoftWare96
Copy link
Contributor Author

Why else the private methods should be documented?

@icebob
Copy link
Member

icebob commented Jan 30, 2020

They are not private methods, just I don't want to cause a breaking change with them. E.g if users (using the previous version of DB service) created create, update...etc methods in their services, and they switched to the newer version, it would cause problems because their custom methods overwrite these new internal methods.

@HighSoftWare96
Copy link
Contributor Author

Mm.. maybe I explained that badly, the propose is only to move the parsingParams inside the private methods.... Is there an actual problem in this? At least you get the params passed to the methods treated just like they were parameters passed directly to the pure API action...
Is there an exact propose for the parsingParams to being out of the private methods?

@icebob
Copy link
Member

icebob commented Jan 31, 2020

No any exact reason.

@HighSoftWare96
Copy link
Contributor Author

So, any ideas on this?

@icebob
Copy link
Member

icebob commented Feb 25, 2020

If we change it, it will cause breaking changes.

@HighSoftWare96
Copy link
Contributor Author

Ok, so this cannot be done or has some meaning and it has to be paused to the next major release?

@icebob
Copy link
Member

icebob commented Feb 26, 2020

We can do it, just we should update the major version. Could you make a PR?

@HighSoftWare96
Copy link
Contributor Author

I will think about that, if I find some time to do that...

@HighSoftWare96
Copy link
Contributor Author

PR made :)

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

No branches or pull requests

2 participants