Skip to main content

toasty_driver_integration_suite/scenarios/
document_optional_code.rs

1use crate::prelude::*;
2
3scenario! {
4    #[derive(Debug, toasty::Model)]
5    #[allow(dead_code)]
6    struct Document {
7        #[key]
8        id: String,
9
10        // Single-field newtype embed: flattens to one column named after the
11        // field, so the nullable head reuses that column rather than a
12        // dedicated (and colliding) presence column.
13        code: Option<Code>,
14    }
15
16    #[derive(Debug, PartialEq, toasty::Embed)]
17    struct Code(String);
18
19    async fn setup(test: &mut Test) -> toasty::Db {
20        test.setup_db(models!(Document)).await
21    }
22}