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

the trait DatabasePool is not implemented for Pool<sqlx::Any> #23

Open
Vai3soh opened this issue Nov 17, 2023 · 3 comments
Open

the trait DatabasePool is not implemented for Pool<sqlx::Any> #23

Vai3soh opened this issue Nov 17, 2023 · 3 comments

Comments

@Vai3soh
Copy link

Vai3soh commented Nov 17, 2023

Hello.

How create object SessionAnyPool if use "Pool<Any>"?

sqlx::any::install_default_drivers();
let any_pool = AnyPoolOptions::new()
    .max_connections(10)
    .connect("sqlite://test.db").await.unwrap();
let session_any_pool = axum_session_auth::SessionAnyPool::new(any_pool);
@genusistimelord
Copy link
Member

you will need to implement it like

https://github.com/AscendingCreations/AxumSession/blob/main/src/databases/postgres.rs

as we do not have SQLx Any in our list due to issues it was having before. Our Any provides a way to use any of the currently made and set databases that we currently support.

so for your case you might not need SQLx Any and instead just use Postgres and SQlite and use the separate parts with our SessionAnyPool. I have updated the Any Example to show you this. https://github.com/AscendingCreations/AxumSession/tree/main/examples/any

@Vai3soh
Copy link
Author

Vai3soh commented Nov 18, 2023

thanks for the example. I thought it was strange that there was a problem with creating a SessionAnyPool. It would be logical to create any_pool and pass it there.

Last question, is there any way to get an object (SessionPgPool or SessionSqlitePool) from any_pool? Depending on what we pass in connect(<pg> or <sqlite>)

@genusistimelord
Copy link
Member

atm there is not, but if you want you can submit a PR to add downcast_ref and downcast_mut.

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