Closed epipheus closed 2 years ago
Hey @epipheus, welcome!! This is the intended behaviour. Please check below for the explanation.
let s: Result<Option<subscription::Model>, DbErr> = Subscription::find()
.one(&db)
.await;
let s: Option<subscription::Model> = Subscription::find()
.one(&db)
.await?; // Note the `?` here
let s: subscription::Model = Subscription::find()
.one(&db)
.await? // Note the `?` here
.expect("Failed to fetch a saved subscription"); // Unwrap the `Option<T>`
Ah.. OK. Guess I missed this somehow. Thank you for responding. Please forgive me for cluttering your issues with this. Is there any gotcha for an async tokio::test? adding a ? yielded the following error: the trait "FromResidual<Result<Infallible, sea_orm::DbErr>>" is not implemented for "()"
No worries! :D
Description
This feels like a bug but could just be my lack of understanding, I'm new to sea-orm and frankly to Rust as well. I wrote a test to fetch model data from the db and instead of it returning None, it returned:
Option<entities::_entity_name_::Model>::None
and as a result the expect failure message doesn't trigger and it moves on. Super weird, right. To actually get the proper panick message I have to do it again.Steps to Reproduce
Am I missing something? When theres an empty fetch I should get a None right?
Expected Behavior
None being returned
Actual Behavior
Option<entities::subscription::Model>::None
is returnedReproduces How Often
Always does this for me
Versions
Additional Information
postgres-db, mac os BigSur