|
@@ -110,7 +110,7 @@ mod manual_test_db {
|
|
|
|
|
|
impl Entity for SimpleEntity {
|
|
|
type Parts = SimpleEntityName;
|
|
|
- type Uniques = SimpleEntityName;
|
|
|
+ type Keys = SimpleEntityName;
|
|
|
type ID = SimpleEntityID;
|
|
|
|
|
|
fn build(name: String) -> Self {
|
|
@@ -203,7 +203,7 @@ mod derive_tests {
|
|
|
|
|
|
#[derive(Entity)]
|
|
|
struct Person {
|
|
|
- #[unique]
|
|
|
+ #[key]
|
|
|
name: String,
|
|
|
roles: AssocMap<Role>,
|
|
|
}
|
|
@@ -230,13 +230,7 @@ mod derive_tests {
|
|
|
// let db = PeopleDB::open_path(":memory:").expect("couldn't open database");
|
|
|
let name_string = "name_here".to_string();
|
|
|
// check that it isn't in the database before we insert it
|
|
|
- assert!(db
|
|
|
- .people
|
|
|
- .unique(&name_string)
|
|
|
- .get()
|
|
|
- .ok()
|
|
|
- .flatten()
|
|
|
- .is_none());
|
|
|
+ assert!(db.people.keyed(&name_string).get().ok().flatten().is_none());
|
|
|
|
|
|
db.people
|
|
|
.insert(Person {
|
|
@@ -246,13 +240,7 @@ mod derive_tests {
|
|
|
.expect("failed to insert");
|
|
|
|
|
|
// check that it is in the database after we insert it
|
|
|
- assert!(db
|
|
|
- .people
|
|
|
- .unique(&name_string)
|
|
|
- .get()
|
|
|
- .ok()
|
|
|
- .flatten()
|
|
|
- .is_some());
|
|
|
+ assert!(db.people.keyed(&name_string).get().ok().flatten().is_some());
|
|
|
}
|
|
|
|
|
|
#[test]
|
|
@@ -269,7 +257,7 @@ mod derive_tests {
|
|
|
|
|
|
let person = db
|
|
|
.people
|
|
|
- .unique(&name_string)
|
|
|
+ .keyed(&name_string)
|
|
|
.get()
|
|
|
.ok()
|
|
|
.flatten()
|
|
@@ -297,7 +285,7 @@ mod derive_tests {
|
|
|
|
|
|
let person = db
|
|
|
.people
|
|
|
- .unique(&name_string)
|
|
|
+ .keyed(&name_string)
|
|
|
.get()
|
|
|
.ok()
|
|
|
.flatten()
|
|
@@ -673,16 +661,16 @@ mod query_equivalence {
|
|
|
use test_log::test;
|
|
|
#[derive(Entity)]
|
|
|
struct SingleItem {
|
|
|
- #[unique]
|
|
|
+ #[key]
|
|
|
s: String,
|
|
|
v: Vec<u8>,
|
|
|
}
|
|
|
|
|
|
#[derive(Entity)]
|
|
|
struct DoubleItem {
|
|
|
- #[unique]
|
|
|
+ #[key]
|
|
|
s: String,
|
|
|
- #[unique]
|
|
|
+ #[key]
|
|
|
t: String,
|
|
|
v: usize,
|
|
|
}
|
|
@@ -713,26 +701,26 @@ mod query_equivalence {
|
|
|
|
|
|
assert!(db
|
|
|
.single_items
|
|
|
- .unique("string 2")
|
|
|
+ .keyed("string 2")
|
|
|
.get()
|
|
|
.expect("couldn't query db")
|
|
|
.is_some());
|
|
|
assert!(db
|
|
|
.single_items
|
|
|
- .unique("string 3")
|
|
|
+ .keyed("string 3")
|
|
|
.get()
|
|
|
.expect("couldn't query db")
|
|
|
.is_none());
|
|
|
|
|
|
assert!(db
|
|
|
.single_items
|
|
|
- .unique(String::from("string 2"))
|
|
|
+ .keyed(String::from("string 2"))
|
|
|
.get()
|
|
|
.expect("couldn't query db")
|
|
|
.is_some());
|
|
|
assert!(db
|
|
|
.single_items
|
|
|
- .unique(String::from("string 3"))
|
|
|
+ .keyed(String::from("string 3"))
|
|
|
.get()
|
|
|
.expect("couldn't query db")
|
|
|
.is_none());
|
|
@@ -760,26 +748,26 @@ mod query_equivalence {
|
|
|
|
|
|
assert!(db
|
|
|
.double_items
|
|
|
- .unique(("string 2", "second string 2"))
|
|
|
+ .keyed(("string 2", "second string 2"))
|
|
|
.get()
|
|
|
.expect("couldn't query db")
|
|
|
.is_some());
|
|
|
assert!(db
|
|
|
.double_items
|
|
|
- .unique(("string 3", "second string 3"))
|
|
|
+ .keyed(("string 3", "second string 3"))
|
|
|
.get()
|
|
|
.expect("couldn't query db")
|
|
|
.is_none());
|
|
|
|
|
|
assert!(db
|
|
|
.double_items
|
|
|
- .unique((String::from("string 2"), String::from("second string 2")))
|
|
|
+ .keyed((String::from("string 2"), String::from("second string 2")))
|
|
|
.get()
|
|
|
.expect("couldn't query db")
|
|
|
.is_some());
|
|
|
assert!(db
|
|
|
.double_items
|
|
|
- .unique((String::from("string 3"), String::from("second string 3")))
|
|
|
+ .keyed((String::from("string 3"), String::from("second string 3")))
|
|
|
.get()
|
|
|
.expect("couldn't query db")
|
|
|
.is_none());
|