Skip to content

feat: add beforePoolAcquire and afterPoolAcquire hooks. - #15859

Merged
ephys merged 21 commits into
sequelize:mainfrom
FilipHavel:main
Mar 31, 2023
Merged

ephys merged 21 commits into
sequelize:mainfrom
FilipHavel:main

Conversation

@FilipHavel

@FilipHavel FilipHavel commented Mar 27, 2023 •

Copy link
Copy Markdown
Contributor

Pull Request Checklist

  • Have you added new tests to prevent regressions?
  • If a documentation update is necessary, have you opened a PR to the documentation repository?
  • Did you update the typescript typings accordingly (if applicable)?
  • Does the description below contain a link to an existing issue (Closes #[issue]) or a description of the issue you are solving?
  • Does the name of your PR follow our conventions?

Description Of Change

Link to issue: #15724

@ephys

ephys commented Mar 27, 2023

Copy link
Copy Markdown
Member

I'm so sorry to change my mind at the last minute on the API name but I think 'after/beforePoolAcquire' would be a better name?

@ephys ephys changed the title feat(postgres): added beforePoolConnection and afterPoolConnection hooks. feat: add beforePoolConnection and afterPoolConnection hooks. Mar 27, 2023
@FilipHavel

Copy link
Copy Markdown
Contributor Author

I'm so sorry to change my mind at the last minute on the API name but I think 'after/beforePoolAcquire' would be a better name?

You're right, the name will be more descriptive this way. Changing the naming is the least. 😄

@FilipHavel

Copy link
Copy Markdown
Contributor Author

@ephys Hooks are renamed. 😄 Some pipeline steps failed, but I don't think this is caused by my changes. I've run those test locally without an error. Please let me know if it's just me who don't see a problem.

@WikiRik

WikiRik commented Mar 27, 2023

Copy link
Copy Markdown
Member

Those are flaky, but I'll rerun them to be sure

@ephys ephys changed the title feat: add beforePoolConnection and afterPoolConnection hooks. feat: add beforePoolAquire and afterPoolAquire hooks. Mar 28, 2023
@ephys ephys changed the title feat: add beforePoolAquire and afterPoolAquire hooks. feat: add beforePoolAcquire and afterPoolAcquire hooks. Mar 28, 2023
@FilipHavel

Copy link
Copy Markdown
Contributor Author

Hi @ephys, I would like to ask you if it would be possible that these changes I made would also be added to the v6, so we can start using it. Of course, if these changes are okay.

@ephys ephys left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this :)

In hooks.test.js, could you add a test that checks that the hook is called when a connection is requested from the pool?

@FilipHavel

Copy link
Copy Markdown
Contributor Author

@ephys I've made PR changes. Some step failed because of connection refused. Is this caused by my changes? I've run tests locally for som dialects and they run without errors. I don't want to spam pipeline with some guessed changes. Can you tell?

@ephys

ephys commented Mar 28, 2023

Copy link
Copy Markdown
Member

Unit tests can't use the database, you'll need to add your test to the integration test folder :)

@FilipHavel

Copy link
Copy Markdown
Contributor Author

@ephys PR is updated 😊 thanks for your help, I didn't notice that im writing it into unit tests.

ephys
ephys previously approved these changes Mar 28, 2023

@ephys ephys left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming tests pass, this looks good to me :)

@FilipHavel

Copy link
Copy Markdown
Contributor Author

@ephys are there any steps that I should take or is that all? As you mentioned in the readme in contribution steps, I also opened some minor changes to the documentation. Will this hook be available in v6 version of sequelize or not for now? 😊 Sorry for many questions but I am curious.

@FilipHavel

FilipHavel commented Mar 29, 2023 •

Copy link
Copy Markdown
Contributor Author

@ephys Hi, I'm trying to fix failed test for sqlite dialect. When I debug it `this.sequelize.authenticate()' is not calling hooks I want (spy is called 0 times). But for example in Postgres it's okay. Can you tell me some possible solutions? I did not work with sqlite in past, so it's harder for me tell why can be this error caused.

@ephys

ephys commented Mar 29, 2023

Copy link
Copy Markdown
Member

Oh I thought I answered this yesterday but I'm not seeing my message 😅
SQLite doesn't use the pool, so you can skip that test if the dialect name is sqlite

Will this hook be available in v6 version of sequelize or not for now?

We can publish in it v6 too. This PR targets the branch used for the v7 release, but if you open the same PR against the v6 branch, I'll be happy to review & release it

I also opened some minor changes to the documentation

I saw :) We'll review it once this & the v6 version are merged

@FilipHavel

Copy link
Copy Markdown
Contributor Author

@ephys PR is updated. You can check. 😊 I'm going to open the same PR against v6. 🙏🏽

ephys
ephys previously approved these changes Mar 29, 2023

@ephys ephys left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks :)

@WikiRik WikiRik left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 small remark, but looks good. Thanks for the PR!

Comment thread packages/core/test/types/hooks.ts Resolved
@FilipHavel

Copy link
Copy Markdown
Contributor Author

@WikiRik No problem, done. 😊

@WikiRik
WikiRik requested a review from ephys March 29, 2023 16:23
@ephys
ephys merged commit 6711351 into sequelize:main Mar 31, 2023
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.

4 participants