fix: ignore deleted products while checking for product names
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/pr/woodpecker Pipeline was successful
ci/woodpecker/pull_request_closed/woodpecker Pipeline was successful

This commit is contained in:
Aravinth Manivannan 2024-07-15 22:36:02 +05:30
parent 8557b68d9d
commit fb50c66ffb
Signed by: realaravinth
GPG key ID: F8F50389936984FF
2 changed files with 15 additions and 2 deletions

View file

@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
"query": "SELECT EXISTS (\n SELECT 1\n FROM cqrs_inventory_product_query\n WHERE\n name = $1\n AND\n category_id = $2\n );",
"query": "SELECT EXISTS (\n SELECT 1\n FROM cqrs_inventory_product_query\n WHERE\n name = $1\n AND\n category_id = $2\n AND\n deleted = false\n );",
"describe": {
"columns": [
{
@ -19,5 +19,5 @@
null
]
},
"hash": "53a5e7e87387ffc14013067a24c80b9d14c9864875177af5320c926d68cfb4ae"
"hash": "ff4bf8b635cd7144238c2df8bb4b13c3e090dc7d6455464b656ff44e0c2c5ebe"
}

View file

@ -19,6 +19,8 @@ impl ProductNameExistsForCategoryDBPort for InventoryDBPostgresAdapter {
name = $1
AND
category_id = $2
AND
deleted = false
);",
s.name(),
s.category_id(),
@ -74,6 +76,17 @@ mod tests {
// state exists
assert!(db.product_name_exists_for_category(&product).await.unwrap());
// Set product.deleted = true; now db.product_name_exists_for_category must return false
sqlx::query!(
"UPDATE cqrs_inventory_product_query SET deleted = true WHERE product_id = $1;",
product.product_id(),
)
.execute(&db.pool)
.await
.unwrap();
assert!(!db.product_name_exists_for_category(&product).await.unwrap());
settings.drop_db().await;
}
}