test(db): cover zero-label term and duplicate vocabulary key; use try_get in vocabulary_by_key
This commit is contained in:
@@ -39,10 +39,7 @@ where
|
||||
.fetch_optional(executor)
|
||||
.await?;
|
||||
|
||||
Ok(row.map(|r| Vocabulary {
|
||||
id: VocabularyId::from_uuid(r.get("id")),
|
||||
key: r.get("key"),
|
||||
}))
|
||||
row.map(map_vocabulary).transpose()
|
||||
}
|
||||
|
||||
/// Insert a term and its labels. Multiple statements — pass a transaction
|
||||
@@ -129,6 +126,13 @@ where
|
||||
Ok(found.map(|_| TermRef::new(term_id, vocabulary_id)))
|
||||
}
|
||||
|
||||
fn map_vocabulary(row: sqlx::postgres::PgRow) -> Result<Vocabulary, sqlx::Error> {
|
||||
Ok(Vocabulary {
|
||||
id: VocabularyId::from_uuid(row.try_get("id")?),
|
||||
key: row.try_get("key")?,
|
||||
})
|
||||
}
|
||||
|
||||
fn map_term(row: sqlx::postgres::PgRow) -> Result<Term, sqlx::Error> {
|
||||
let labels: sqlx::types::Json<Vec<LocalizedLabel>> = row.try_get("labels")?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user