AscendingCreations / AxumSessionAuth

Library to Provide a User Authentication and privilege Token Checks.
MIT License
111 stars 11 forks source link

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

Open Vai3soh opened 1 year ago

Vai3soh commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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