AscendingCreations / AxumSession

Axum Session Management Libraries that use Sqlx
MIT License
136 stars 28 forks source link

feature key-store panics when database is not seeded #57

Closed beckend closed 10 months ago

beckend commented 10 months ago

https://github.com/AscendingCreations/AxumSession/blob/main/src/session_store.rs#L84-L106

It's not possible to seed the database unless you create a session store, but with the feature, we don't get that chance.

genusistimelord commented 10 months ago

ahh your talking about the Else statements how its not using the config. That is a easy enough fix as they should of been using that. Or do you mean something else like adding UUID's manually to the filter? @beckend

beckend commented 10 months ago

I think I mean that this line errors, since the database has no such table yet, I am getting of course a db error:

           let ids = client.get_ids(&config.table_name).await?;

This phase is creating the session store, however the session store lets you do .initiate() only after creation.

Error: creating session store

Caused by:
    0: error returned from database: relation "sessions" does not exist
    1: relation "sessions" does not exist
genusistimelord commented 10 months ago

Yeah good catch.

I can do this in one of two ways 1.) make new create the Table if it does not Exist. 2.) Split the Filter seeding off into its own function to be called later.

Personally 1 would be better since its only called Once and it requires less work on the Developers using the crate. It also means less Errors on the developer side for forgetting to do it themselves. But it means a API change.

2 would mean adding a new function which would be a fix but people could forget to call it which results in UUID not making it into the filter table so id prefer against this. So I will work on the latter since this makes more sense in the long run.

beckend commented 10 months ago

Vote for 1.

genusistimelord commented 10 months ago

Ok I have published a new release that should fix this problem. Please give it a test.

beckend commented 10 months ago
axum_session = { version = '0.5.0', default-features = false, features = [
  'postgres-native',
  'fastbloom-rs',
  'key-store',
] }

now works as expected.