diff --git a/.sqlx/query-5944442c15d28d47654afae92815ccefea89cc9aee705e0e1e54a3bf884bb194.json b/.sqlx/query-7acab15a75b02104059e95c24ade45836ccb6745ff2096f1d4f733b702142ca0.json similarity index 72% rename from .sqlx/query-5944442c15d28d47654afae92815ccefea89cc9aee705e0e1e54a3bf884bb194.json rename to .sqlx/query-7acab15a75b02104059e95c24ade45836ccb6745ff2096f1d4f733b702142ca0.json index 8ff850c..42c3b14 100644 --- a/.sqlx/query-5944442c15d28d47654afae92815ccefea89cc9aee705e0e1e54a3bf884bb194.json +++ b/.sqlx/query-7acab15a75b02104059e95c24ade45836ccb6745ff2096f1d4f733b702142ca0.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "SELECT EXISTS (\n SELECT 1\n FROM cqrs_inventory_category_query\n WHERE\n name = $1\n AND\n store_id = $2\n );", + "query": "SELECT EXISTS (\n SELECT 1\n FROM cqrs_inventory_category_query\n WHERE\n name = $1\n AND\n store_id = $2\n AND\n deleted = false\n );", "describe": { "columns": [ { @@ -19,5 +19,5 @@ null ] }, - "hash": "5944442c15d28d47654afae92815ccefea89cc9aee705e0e1e54a3bf884bb194" + "hash": "7acab15a75b02104059e95c24ade45836ccb6745ff2096f1d4f733b702142ca0" } diff --git a/src/inventory/adapters/output/db/postgres/category_name_exists_for_store.rs b/src/inventory/adapters/output/db/postgres/category_name_exists_for_store.rs index 3dab26a..194d395 100644 --- a/src/inventory/adapters/output/db/postgres/category_name_exists_for_store.rs +++ b/src/inventory/adapters/output/db/postgres/category_name_exists_for_store.rs @@ -19,6 +19,8 @@ impl CategoryNameExistsForStoreDBPort for InventoryDBPostgresAdapter { name = $1 AND store_id = $2 + AND + deleted = false );", s.name(), s.store_id(), @@ -85,6 +87,18 @@ pub mod tests { // state exists assert!(db.category_name_exists_for_store(&category).await.unwrap()); + + // Set category.deleted = true; now db.category_name_exists_for_store must return false + sqlx::query!( + "UPDATE cqrs_inventory_category_query SET deleted = true WHERE category_id = $1;", + category.category_id(), + ) + .execute(&db.pool) + .await + .unwrap(); + assert!(!db.category_name_exists_for_store(&category).await.unwrap()); + + settings.drop_db().await; } } diff --git a/src/inventory/adapters/output/db/postgres/store_name_exists.rs b/src/inventory/adapters/output/db/postgres/store_name_exists.rs index 279c44c..81da3be 100644 --- a/src/inventory/adapters/output/db/postgres/store_name_exists.rs +++ b/src/inventory/adapters/output/db/postgres/store_name_exists.rs @@ -66,7 +66,7 @@ mod tests { // state exists assert!(db.store_name_exists(&store).await.unwrap()); - // Set store.deleted = true; now db.store_id_exists must return false + // Set store.deleted = true; now db.store_name_exists must return false sqlx::query!( "UPDATE cqrs_inventory_store_query SET deleted = true WHERE store_id = $1;", store.store_id()