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

DatabaseConnection is not Send, Sync and Clone #152

Closed
tqwewe opened this issue Sep 12, 2021 · 2 comments
Closed

DatabaseConnection is not Send, Sync and Clone #152

tqwewe opened this issue Sep 12, 2021 · 2 comments

Comments

@tqwewe
Copy link
Contributor

tqwewe commented Sep 12, 2021

SeaORM's DatabaseConnection type is not Send, Sync and Clone.
These should be easily added as DatabaseConnection is a wrapper of the Sqlx pool types, which themselves are Send, Sync and Clone.

On the Sqlx Pool documentation:

Pool is Send, Sync and Clone, so it should be created once at the start of your application/daemon/web server/etc. and then shared with all tasks throughout its lifetime.

This is usually needed for many apps, such as an actix server, so it can be sent between threads to aquire new connections.

@tyt2y3
Copy link
Member

tyt2y3 commented Sep 15, 2021

I think it is Send and Sync already, but not Clone because Mock is not intended to be cloned.

https://docs.rs/sea-orm/0.2.1/sea_orm/enum.DatabaseConnection.html#synthetic-implementations

@tyt2y3
Copy link
Member

tyt2y3 commented Sep 15, 2021

The PR changed the behavior to impl Clone only when Mock is not enabled.

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