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

thread '<unnamed>' panicked at 'called Option::unwrap() on a None value', #2110

Closed
1 task done
joe-at-startupmedia opened this issue Jul 7, 2019 · 1 comment
Closed
1 task done

Comments

@joe-at-startupmedia
Copy link

joe-at-startupmedia commented Jul 7, 2019

Versions

rustc 1.35.0 (3c235d560 2019-05-20)
diesel = { version = "1.4.2", features = ["postgres", "uuidv07", "r2d2", "chrono"] }
inux localhost.localdomain 3.10.0-693.17.1.el7.x86_64 #1 SMP Thu Jan 25 20:13:58 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

What are you trying to accomplish?

I am trying to populate a table with nullable values and retrieve the record from the tables without panics or errors due to the columns being null

What is the expected output?

To unwrap a model with nullable values of None

What is the actual output?

thread '' panicked at 'called Option::unwrap() on a None value',

Steps to reproduce

I have the following model specification:

#[derive(Debug, Serialize, Deserialize, Queryable, Insertable, AsChangeset)]
#[table_name = "refresh_tokens"]
#[changeset_options(treat_none_as_null = "true")]
pub struct RefreshToken {
    pub id: Uuid,
    pub user_id: Uuid,
    pub token: String,
    pub created_at: NaiveDateTime,
    pub expires_at: NaiveDateTime,
    pub salt: String,
    pub renewed_on: Option<NaiveDateTime>,
    pub renewed_with: Option<Uuid>,
}

I've add AsChangeset derivation annotation along with #[changeset_options(treat_none_as_null = "true")]

In an attempt to solve the following error:

thread '<unnamed>' panicked at 'called `Option::unwrap()` on a `None` value', src/libcore/option.rs:345:21
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
             at src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:39
   1: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:71
   2: std::panicking::default_hook::{{closure}}
             at src/libstd/sys_common/backtrace.rs:59
             at src/libstd/panicking.rs:197
   3: std::panicking::default_hook
             at src/libstd/panicking.rs:211
   4: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:474
   5: std::panicking::continue_panic_fmt
             at src/libstd/panicking.rs:381
   6: rust_begin_unwind
             at src/libstd/panicking.rs:308
   7: core::panicking::panic_fmt
             at src/libcore/panicking.rs:85
   8: core::panicking::panic
             at src/libcore/panicking.rs:49
   9: core::option::Option<T>::unwrap
             at /rustc/3c235d5600393dfe6c36eeed34042efad8d4f26e/src/libcore/macros.rs:12
  10: user_api::refreshtoken_handler::<impl actix::handler::Handler<user_api::refreshtoken_handler::RefreshRenewRequest> for user_api::models::DbExecutor>::handle
             at src/refreshtoken_handler.rs:77
  11: <actix::sync::SyncContextEnvelope<A,M> as actix::address::envelope::EnvelopeProxy>::handle
             at /home/vagrant/.cargo/registry/src/github.com-1ecc6299db9ec823/actix-0.8.3/src/sync.rs:353
  12: <actix::address::envelope::Envelope<A> as actix::address::envelope::EnvelopeProxy>::handle
             at /home/vagrant/.cargo/registry/src/github.com-1ecc6299db9ec823/actix-0.8.3/src/address/envelope.rs:71
  13: actix::sync::SyncContext<A>::run
             at /home/vagrant/.cargo/registry/src/github.com-1ecc6299db9ec823/actix-0.8.3/src/sync.rs:251
  14: actix::sync::SyncArbiter<A>::start::{{closure}}
             at /home/vagrant/.cargo/registry/src/github.com-1ecc6299db9ec823/actix-0.8.3/src/sync.rs:122

Checklist

  • I have already looked over the issue tracker for similar issues.

Seems similar to #885

@joe-at-startupmedia
Copy link
Author

The issue was that I was unwrapping an empty result of None. Had nothing to do with the columns themselves being None.

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

1 participant