You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So, i’m modeling a bunch of relational data in redb, and i’m using all the NonZero… types as primary keys for their Option<NonZero…> optimisations where i store foreign keys. Thanks to the orphan rule, i currently have to jump through ugly wrapper type hoops to get that done. It would be nice if a built-in solution could be provided instead.
Hypothetically, it is possible that an invalid primary key 0 somehow makes its way into the database file, which means that reading a NonZero… primary key from the database is fallible. Here’s a few suggestions for what could be done in that should-not-happen case, and which one i’d favour:
Treat reading a 0 key as »no entry found«, returning None. I’d prefer this behaviour.
Keeps the app running, delegating this case to special logic an app already has to consider.
However, this means that ID=0 data inside the database is a zombie data resource leak.
Add a new error return code, for ID=0 is an example of database corruption.
Pretty harsh, though, for otherwise the DB seems to work fine, and it’s just unreachable data.
It would be good to then also specialise Option<NonZero…> to just map to .unwrap_or(0) as a redb::Value.
The text was updated successfully, but these errors were encountered:
I think the Rust specialization feature is required to implement it for Option<NonZero> because there is already an impl for Option<T>. You probably need to implement your own MyKey that wraps an Option<NonZero>
Hello, there!
So, i’m modeling a bunch of relational data in redb, and i’m using all the
NonZero…
types as primary keys for theirOption<NonZero…>
optimisations where i store foreign keys. Thanks to the orphan rule, i currently have to jump through ugly wrapper type hoops to get that done. It would be nice if a built-in solution could be provided instead.Hypothetically, it is possible that an invalid primary key 0 somehow makes its way into the database file, which means that reading a
NonZero…
primary key from the database is fallible. Here’s a few suggestions for what could be done in that should-not-happen case, and which one i’d favour:None
. I’d prefer this behaviour.It would be good to then also specialise
Option<NonZero…>
to just map to.unwrap_or(0)
as aredb::Value
.The text was updated successfully, but these errors were encountered: