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
Consider extending instead of mutating? #9
Comments
Good idea. Maybe After all, I don't think it's common to be creating Clients/Pools frequently by hand so there aren't too many opportunities to create a |
|
Agreed. It's been the main defect of this library and something I wasn't happy with. I'm currently taking a break from programming for a month or two. If you have the motivation, energy, and were thinking of submitting a PR, I certainly would be interested. |
TODO: Update readme and publish major point release. |
Alright, updated readme and published 2.x. https://github.com/danneu/koa-skeleton was updated to use pg-extra 2.x. Thanks again. |
As the title says, consider extending pg.Pool and pg.Client instead of mutating them and storing them on a separate property of pg.
For example for
pg.Client
Since it now uses
pg._Client
, this would be a major update because of the breaking changes. In this way, you avoid mutating the original class, and still prevents accidental sql injection, assuming user usesnew pg._Client()
instead of the originalnew pg.Client()
As for pg.Pool, until this brianc/node-postgres#1541 pull request gets merged, You would need to directly extend
pg-pool
yourself.For example for
pg.Pool
:The same thing with
pg._Client
, user will now have to usepg._Pool
and this breaks and should be a major update.On both implementation, user are still able to access the original/non-mutated
pg.Pool
andpg.Client
Another approach without breaking changes would be to clone
pg.Pool
andpg.Client
topg._Pool
andpg._Client
and extendpg.Pool
andpg.Client
instead. This way,_Pool
and_Client
will serve as the original/non-mutated classes.The text was updated successfully, but these errors were encountered: