Nullable Vec<u8> type
On sea_orm 2 RC38.
I'm trying to implement a newtype that's not stringy, not an enum, but a binary type, [TorrentFile](https://github.com/angrynode/hightorrent/blob/feat-sea-orm/src/torrent_file.rs#L335).
I'm probably doing something wrong because i can't seem to be able to do `Option<TorrentFile>` in a sea_orm model. The type implements `Nullable` [here](https://github.com/angrynode/hightorrent/blob/feat-sea-orm/src/torrent_file.rs#L386).
In [my model](https://github.com/angrynode/torrentmanager/blob/magnet-form3/src/database/magnet.rs#L20), i've tried to specify `#[sea_orm(default_value = "None", nullable)]` even though i don't think it would be necessary. In [the migration](https://github.com/angrynode/torrentmanager/blob/magnet-form3/src/migration/m20251114_01_create_table_magnet.rs#L21), i've tried both `var_binary(...).null()` and `binary(...).null()`
The error i get at runtime is `Type Error: A null value was encountered while decoding "resolved"`. It only occurs when loading the table, after a magnet was inserted with `resolved = NULL`.
My understanding is that this should only happening [when encountering `TryGetError::Null`](https://github.com/SeaQL/sea-orm/blob/3d33b516e969d936a97f2c89d968c269ed3f62c7/src/executor/query.rs#L69), but in that case the implementation for `Option<T>` [should produce `Ok(None)`](https://github.com/SeaQL/sea-orm/blob/3d33b516e969d936a97f2c89d968c269ed3f62c7/src/executor/query.rs#L297).
There's probably something missing in my mental model. I'll be happy to help improve the docs about binary newtypes if i can understand what's wrong :)
I've added the label "bug" because it's a runtime error and not a compile-time error.
3 条评论