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

afterConnect hook doesn't work with SQLite #12487

Open
2 of 7 tasks
bradisbell opened this issue Jul 10, 2020 · 6 comments
Open
2 of 7 tasks

afterConnect hook doesn't work with SQLite #12487

bradisbell opened this issue Jul 10, 2020 · 6 comments
Assignees
Labels
dialect: sqlite For issues and PRs. Things that involve SQLite (and do not involve all dialects). type: bug

Comments

@bradisbell
Copy link

Issue Description

What are you doing?

Attempting to register an afterConnect() hook.

const Sequelize = require('sequelize');

const sequelize = new Sequelize({
  dialect: 'sqlite',
  storage: 'db.sqlite',
});

sequelize.afterConnect(async (connection, config) => {
  console.log('HOOK CALLED'); // <<< Never happens
  connection.query('PRAGMA journal_mode=WAL;');
});

sequelize.authenticate().then(/* model setup, etc. here */);

What do you expect to happen?

I expected the hook to be called.

What is actually happening?

The hook simply never gets called. No error occurs when the hook is registered.

Environment

  • Sequelize version: 5.21.2
  • Node.js version: 12.11.1
  • Operating System: Windows 10 x64

Issue Template Checklist

How does this problem relate to dialects?

  • I think this problem happens regardless of the dialect.
  • I think this problem happens only for the following dialect(s):
  • I don't know, I was using sqlite, with connector library version 5.0.0 and database version XXX

Would you be willing to resolve this issue by submitting a Pull Request?

  • Yes, I have the time and I know how to start.
  • Yes, I have the time but I don't know how to start, I would need guidance.
  • No, I don't have the time, although I believe I could do it if I had the time...
  • No, I don't have the time and I wouldn't even know how to start.
@sushantdhiman sushantdhiman added type: bug dialect: sqlite For issues and PRs. Things that involve SQLite (and do not involve all dialects). labels Jul 11, 2020
@github-actions
Copy link
Contributor

github-actions bot commented Nov 2, 2021

This issue has been automatically marked as stale because it has been open for 7 days without activity. It will be closed if no further activity occurs. If this is still an issue, just leave a comment or remove the "stale" label. 🙂

@github-actions github-actions bot added the stale label Nov 2, 2021
@github-actions github-actions bot closed this as completed Nov 8, 2021
@bradisbell
Copy link
Author

Not stale.

@WikiRik WikiRik reopened this Jan 31, 2022
@WikiRik WikiRik removed the stale label Jan 31, 2022
@nlwillia
Copy link

We were trying to setup migrations for in-memory sqlite tests and couldn't figure out why the hooks weren't working. 😩 It would be great to see this fixed.

@WikiRik
Copy link
Member

WikiRik commented Mar 16, 2022

It seems that there was a PR that could solve this issue. I'll see if I can patch that one up and get it working with the current version next week

@WikiRik WikiRik self-assigned this Mar 16, 2022
@msbsh
Copy link

msbsh commented Aug 30, 2022

@WikiRik any updates?

@megahypercat
Copy link

We really need support for performance optimizations with sequelize. This is one of them.
It's really unfortunate when you build something but as it grows, sequelize becomes a major performance bottleneck.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dialect: sqlite For issues and PRs. Things that involve SQLite (and do not involve all dialects). type: bug
Projects
None yet
Development

No branches or pull requests

6 participants