MCPcopy Create free account
hub / github.com/SeaQL/sea-orm / create_and_update_metadata

Function create_and_update_metadata

tests/uuid_tests.rs:58–88  ·  view source on GitHub ↗
(db: &DatabaseConnection)

Source from the content-addressed store, hash-verified

56}
57
58pub async fn create_and_update_metadata(db: &DatabaseConnection) -> Result<(), DbErr> {
59 let metadata = metadata::Model {
60 uuid: Uuid::new_v4(),
61 ty: "Type".to_owned(),
62 key: "markup".to_owned(),
63 value: "1.18".to_owned(),
64 bytes: vec![1, 2, 3],
65 date: Some(Date::from_ymd_opt(2021, 9, 27).unwrap()),
66 time: Some(Time::from_hms_opt(11, 32, 55).unwrap()),
67 };
68
69 let res = Metadata::insert(metadata.clone().into_active_model())
70 .exec(db)
71 .await?;
72
73 assert_eq!(Metadata::find().one(db).await?, Some(metadata.clone()));
74
75 assert_eq!(res.last_insert_id, metadata.uuid);
76
77 let update_res = Metadata::update(metadata::ActiveModel {
78 value: Set("0.22".to_owned()),
79 ..metadata.clone().into_active_model()
80 })
81 .filter(metadata::Column::Uuid.eq(Uuid::default()))
82 .exec(db)
83 .await;
84
85 assert_eq!(update_res, Err(DbErr::RecordNotUpdated));
86
87 Ok(())
88}

Callers 1

mainFunction · 0.85

Calls 6

unwrapMethod · 0.80
into_active_modelMethod · 0.80
filterMethod · 0.80
updateFunction · 0.50
execMethod · 0.45
eqMethod · 0.45

Tested by

no test coverage detected