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

feat: Support for lazy database connections #2268

Merged
merged 1 commit into from
Aug 21, 2024

Conversation

spencewenski
Copy link
Contributor

@spencewenski spencewenski commented Jun 22, 2024

PR Info

  • Dependencies: N/A
  • Dependents: N/A

New Features

Add support for creating DB connection pools without establishing connections up front. This is already supported by SQLx via the Pool::connect_lazy method.

This was discussed previously
here, but it appears support was never added to SEA ORM directly.

Bug Fixes

  • N/A

Breaking Changes

  • N/A

Changes

This PR adds a new connect_lazy option to database::ConnectOptions. If set to true, the SQLx Pool will be created using the Pool::connect_lazy_with method; otherwise, the Pool::connect_with method will be used (e.g., the existing behavior). This "lazy" behavior is implemented for each DB variant (Postgres/MySQL/SQLite).

Add support for creating DB connection pools without establishing
connections up front. This is already supported by SQLx via the
[Pool::connect_lazy](https://docs.rs/sqlx/latest/sqlx/struct.Pool.html#method.connect_lazy)
method.

This PR adds a new `connect_lazy` option to `database::ConnectOptions`.
If set to `true`, the SQLx `Pool` will be created using the
`Pool::connect_lazy_with` method; otherwise, the `Pool::connect_with`
method will be used (e.g., the existing behavior). This "lazy" behavior
is implemented for each DB variant (Postgres/MySQL/SQLite).

This was discussed previously
[here](SeaQL#1645), but it
appears support was never added to SEA ORM directly.
@spencewenski
Copy link
Contributor Author

Hey @billy1624 , @tyt2y3 , can you take a look at this when you get a chance? Or assign to someone else to review? Thanks!

@spencewenski
Copy link
Contributor Author

Hey @billy1624 and @tyt2y3 sorry to ping you again. Can you take a look when you get a chance? Thanks!

Copy link
Member

@billy1624 billy1624 left a comment

Choose a reason for hiding this comment

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

Hey @spencewenski, sorry for the delay! This looks good to me :)

@billy1624 billy1624 requested a review from tyt2y3 July 4, 2024 06:47
@spencewenski
Copy link
Contributor Author

Great, thanks for the approval, @billy1624! And no worries! I understand you’re probably busy.

@spencewenski
Copy link
Contributor Author

Hey @tyt2y3, any chance you can take a look at this soon? Or let me know approximately when you’ll be able to take a look?

@spencewenski
Copy link
Contributor Author

Hey @billy1624 and @tyt2y3, just wondering when we can get this merged since it’s been approved for a while now. Thanks!

@tyt2y3
Copy link
Member

tyt2y3 commented Aug 20, 2024

Thank you

@tyt2y3 tyt2y3 merged commit 4553160 into SeaQL:master Aug 21, 2024
35 checks passed
tyt2y3 pushed a commit that referenced this pull request Aug 21, 2024
Add support for creating DB connection pools without establishing
connections up front. This is already supported by SQLx via the
[Pool::connect_lazy](https://docs.rs/sqlx/latest/sqlx/struct.Pool.html#method.connect_lazy)
method.

This PR adds a new `connect_lazy` option to `database::ConnectOptions`.
If set to `true`, the SQLx `Pool` will be created using the
`Pool::connect_lazy_with` method; otherwise, the `Pool::connect_with`
method will be used (e.g., the existing behavior). This "lazy" behavior
is implemented for each DB variant (Postgres/MySQL/SQLite).

This was discussed previously
[here](#1645), but it
appears support was never added to SEA ORM directly.
Copy link

🎉 Released In 1.0.1 🎉

Thank you everyone for the contribution!
This feature is now available in the latest release. Now is a good time to upgrade!
Your participation is what makes us unique; your adoption is what drives us forward.
You can support SeaQL 🌊 by starring our repos, sharing our libraries and becoming a sponsor ⭐.

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.

3 participants