MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / constraint_set_operations

Function constraint_set_operations

nodedb-crdt/src/constraint.rs:166–181  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

164
165 #[test]
166 fn constraint_set_operations() {
167 let mut cs = ConstraintSet::new();
168 cs.add_unique("users_email_unique", "users", "email");
169 cs.add_not_null("users_name_nn", "users", "name");
170 cs.add_foreign_key("posts_author_fk", "posts", "author_id", "users", "id");
171 cs.add_bitemporal_fk("orders_user_btfk", "orders", "user_id", "users", "id");
172
173 assert_eq!(cs.len(), 4);
174 assert_eq!(cs.for_collection("users").len(), 2);
175 assert_eq!(cs.for_collection("posts").len(), 1);
176 assert_eq!(cs.for_collection("orders").len(), 1);
177 assert_eq!(cs.for_collection("missing").len(), 0);
178
179 let btfk = cs.for_collection("orders")[0];
180 assert!(matches!(btfk.kind, ConstraintKind::BiTemporalFK { .. }));
181 }
182}

Callers

nothing calls this directly

Calls 5

add_uniqueMethod · 0.80
add_not_nullMethod · 0.80
add_foreign_keyMethod · 0.80
add_bitemporal_fkMethod · 0.80
for_collectionMethod · 0.80

Tested by

no test coverage detected