diff --git a/.sqlx/query-05ace802a2cd4162fee18286b56602494ae1d022bc9743d08e87c5ac1805f623.json b/.sqlx/query-05ace802a2cd4162fee18286b56602494ae1d022bc9743d08e87c5ac1805f623.json new file mode 100644 index 0000000..0e6e41c --- /dev/null +++ b/.sqlx/query-05ace802a2cd4162fee18286b56602494ae1d022bc9743d08e87c5ac1805f623.json @@ -0,0 +1,19 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO cqrs_inventory_store_query (\n version, name, address, store_id, owner, deleted\n ) VALUES (\n $1, $2, $3, $4, $5, $6\n );", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Int8", + "Text", + "Text", + "Uuid", + "Uuid", + "Bool" + ] + }, + "nullable": [] + }, + "hash": "05ace802a2cd4162fee18286b56602494ae1d022bc9743d08e87c5ac1805f623" +} diff --git a/.sqlx/query-48aa5f3eacaaec4a74ba5d2908875fcac797644d104d3d580715587ecb2e2119.json b/.sqlx/query-0ccd86643c13d9d7c793f362aedc2d720d9dda982a0416849bf97291fc645ea5.json similarity index 71% rename from .sqlx/query-48aa5f3eacaaec4a74ba5d2908875fcac797644d104d3d580715587ecb2e2119.json rename to .sqlx/query-0ccd86643c13d9d7c793f362aedc2d720d9dda982a0416849bf97291fc645ea5.json index 37e701b..f0b010a 100644 --- a/.sqlx/query-48aa5f3eacaaec4a74ba5d2908875fcac797644d104d3d580715587ecb2e2119.json +++ b/.sqlx/query-0ccd86643c13d9d7c793f362aedc2d720d9dda982a0416849bf97291fc645ea5.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "UPDATE\n cqrs_inventory_store_query\n SET\n version = $1,\n name = $2,\n address = $3,\n store_id = $4,\n owner = $5;", + "query": "UPDATE\n cqrs_inventory_store_query\n SET\n version = $1,\n name = $2,\n address = $3,\n store_id = $4,\n owner = $5,\n deleted = $6;", "describe": { "columns": [], "parameters": { @@ -9,10 +9,11 @@ "Text", "Text", "Uuid", - "Uuid" + "Uuid", + "Bool" ] }, "nullable": [] }, - "hash": "48aa5f3eacaaec4a74ba5d2908875fcac797644d104d3d580715587ecb2e2119" + "hash": "0ccd86643c13d9d7c793f362aedc2d720d9dda982a0416849bf97291fc645ea5" } diff --git a/.sqlx/query-4389b997a21aa5184102aaf7c90fc527776e7a753b12bf7035904dedde904aae.json b/.sqlx/query-398a5dc0ffc9f892255ebfd67e1583f5cf092d871a9a710ca4f59e14d08aaf8e.json similarity index 73% rename from .sqlx/query-4389b997a21aa5184102aaf7c90fc527776e7a753b12bf7035904dedde904aae.json rename to .sqlx/query-398a5dc0ffc9f892255ebfd67e1583f5cf092d871a9a710ca4f59e14d08aaf8e.json index 923f7f5..66962fb 100644 --- a/.sqlx/query-4389b997a21aa5184102aaf7c90fc527776e7a753b12bf7035904dedde904aae.json +++ b/.sqlx/query-398a5dc0ffc9f892255ebfd67e1583f5cf092d871a9a710ca4f59e14d08aaf8e.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "SELECT \n name,\n description,\n image,\n product_id,\n category_id,\n price_major,\n price_minor,\n price_currency,\n sku_able\n FROM\n cqrs_inventory_product_query\n WHERE\n product_id = $1;", + "query": "SELECT \n name,\n description,\n image,\n product_id,\n category_id,\n price_major,\n price_minor,\n price_currency,\n sku_able,\n quantity_unit,\n quantity_number\n FROM\n cqrs_inventory_product_query\n WHERE\n product_id = $1;", "describe": { "columns": [ { @@ -47,6 +47,16 @@ "ordinal": 8, "name": "sku_able", "type_info": "Bool" + }, + { + "ordinal": 9, + "name": "quantity_unit", + "type_info": "Text" + }, + { + "ordinal": 10, + "name": "quantity_number", + "type_info": "Int4" } ], "parameters": { @@ -63,8 +73,10 @@ false, false, false, + false, + false, false ] }, - "hash": "4389b997a21aa5184102aaf7c90fc527776e7a753b12bf7035904dedde904aae" + "hash": "398a5dc0ffc9f892255ebfd67e1583f5cf092d871a9a710ca4f59e14d08aaf8e" } diff --git a/.sqlx/query-b84fb940a2aa673d3b19b2317e1e3436d3983e8a32400bbcefd91efb945190cd.json b/.sqlx/query-56be64ebc41f5fc5bc0c6fbf06515798a2806685f5af8ba9f986a0835534b061.json similarity index 68% rename from .sqlx/query-b84fb940a2aa673d3b19b2317e1e3436d3983e8a32400bbcefd91efb945190cd.json rename to .sqlx/query-56be64ebc41f5fc5bc0c6fbf06515798a2806685f5af8ba9f986a0835534b061.json index 57a2ff3..c933889 100644 --- a/.sqlx/query-b84fb940a2aa673d3b19b2317e1e3436d3983e8a32400bbcefd91efb945190cd.json +++ b/.sqlx/query-56be64ebc41f5fc5bc0c6fbf06515798a2806685f5af8ba9f986a0835534b061.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "SELECT EXISTS (\n SELECT 1\n FROM cqrs_inventory_store_query\n WHERE\n name = $1\n );", + "query": "SELECT EXISTS (\n SELECT 1\n FROM cqrs_inventory_store_query\n WHERE\n name = $1\n AND\n deleted = false\n );", "describe": { "columns": [ { @@ -18,5 +18,5 @@ null ] }, - "hash": "b84fb940a2aa673d3b19b2317e1e3436d3983e8a32400bbcefd91efb945190cd" + "hash": "56be64ebc41f5fc5bc0c6fbf06515798a2806685f5af8ba9f986a0835534b061" } diff --git a/.sqlx/query-4d3524bb1742ba55267ab53322cf6c6942d6fc4057b65327f8c6d79ef21cc064.json b/.sqlx/query-60fb3bb1d459b64f900cf02d7d2444b2183bd4d1a4af3a93336091f3c2bdcace.json similarity index 72% rename from .sqlx/query-4d3524bb1742ba55267ab53322cf6c6942d6fc4057b65327f8c6d79ef21cc064.json rename to .sqlx/query-60fb3bb1d459b64f900cf02d7d2444b2183bd4d1a4af3a93336091f3c2bdcace.json index cc910f8..1a5cf00 100644 --- a/.sqlx/query-4d3524bb1742ba55267ab53322cf6c6942d6fc4057b65327f8c6d79ef21cc064.json +++ b/.sqlx/query-60fb3bb1d459b64f900cf02d7d2444b2183bd4d1a4af3a93336091f3c2bdcace.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "UPDATE\n cqrs_inventory_product_query\n SET\n version = $1,\n name = $2,\n description = $3,\n image = $4,\n product_id = $5,\n category_id = $6,\n price_major = $7,\n price_minor = $8,\n price_currency = $9,\n sku_able = $10;", + "query": "UPDATE\n cqrs_inventory_product_query\n SET\n version = $1,\n name = $2,\n description = $3,\n image = $4,\n product_id = $5,\n category_id = $6,\n price_major = $7,\n price_minor = $8,\n price_currency = $9,\n sku_able = $10,\n quantity_unit = $11,\n quantity_number = $12;", "describe": { "columns": [], "parameters": { @@ -14,10 +14,12 @@ "Int4", "Int4", "Text", - "Bool" + "Bool", + "Text", + "Int4" ] }, "nullable": [] }, - "hash": "4d3524bb1742ba55267ab53322cf6c6942d6fc4057b65327f8c6d79ef21cc064" + "hash": "60fb3bb1d459b64f900cf02d7d2444b2183bd4d1a4af3a93336091f3c2bdcace" } diff --git a/.sqlx/query-3c82b22884858afc80ab013abddc072c816f5ea94eac454406f5eaa3129dd180.json b/.sqlx/query-727e8a82469f1887a7136900d45cfb4e3b6c0ddeb0c3610ec5a9f80e0b1c227e.json similarity index 64% rename from .sqlx/query-3c82b22884858afc80ab013abddc072c816f5ea94eac454406f5eaa3129dd180.json rename to .sqlx/query-727e8a82469f1887a7136900d45cfb4e3b6c0ddeb0c3610ec5a9f80e0b1c227e.json index ed65490..b26993b 100644 --- a/.sqlx/query-3c82b22884858afc80ab013abddc072c816f5ea94eac454406f5eaa3129dd180.json +++ b/.sqlx/query-727e8a82469f1887a7136900d45cfb4e3b6c0ddeb0c3610ec5a9f80e0b1c227e.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "INSERT INTO cqrs_inventory_product_query (\n version,\n name,\n description,\n image,\n product_id,\n category_id,\n price_major,\n price_minor,\n price_currency,\n sku_able\n ) VALUES (\n $1, $2, $3, $4, $5, $6, $7, $8, $9, $10\n );", + "query": "INSERT INTO cqrs_inventory_product_query (\n version,\n name,\n description,\n image,\n product_id,\n category_id,\n price_major,\n price_minor,\n price_currency,\n sku_able,\n quantity_unit,\n quantity_number\n ) VALUES (\n $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12\n );", "describe": { "columns": [], "parameters": { @@ -14,10 +14,12 @@ "Int4", "Int4", "Text", - "Bool" + "Bool", + "Text", + "Int4" ] }, "nullable": [] }, - "hash": "3c82b22884858afc80ab013abddc072c816f5ea94eac454406f5eaa3129dd180" + "hash": "727e8a82469f1887a7136900d45cfb4e3b6c0ddeb0c3610ec5a9f80e0b1c227e" } diff --git a/.sqlx/query-5385ba9531992b91670e52b5332af1f09069e1d6d168f9e93b729cf964e97c35.json b/.sqlx/query-8019c47351303c392784405ac53a46c9ad10015d4afd5bba97d21eff71b12436.json similarity index 67% rename from .sqlx/query-5385ba9531992b91670e52b5332af1f09069e1d6d168f9e93b729cf964e97c35.json rename to .sqlx/query-8019c47351303c392784405ac53a46c9ad10015d4afd5bba97d21eff71b12436.json index 2e101fa..fcb8f0d 100644 --- a/.sqlx/query-5385ba9531992b91670e52b5332af1f09069e1d6d168f9e93b729cf964e97c35.json +++ b/.sqlx/query-8019c47351303c392784405ac53a46c9ad10015d4afd5bba97d21eff71b12436.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "SELECT \n name, address, store_id, owner\n FROM\n cqrs_inventory_store_query\n WHERE\n store_id = $1;", + "query": "SELECT \n name, address, store_id, owner, deleted\n FROM\n cqrs_inventory_store_query\n WHERE\n store_id = $1;", "describe": { "columns": [ { @@ -22,6 +22,11 @@ "ordinal": 3, "name": "owner", "type_info": "Uuid" + }, + { + "ordinal": 4, + "name": "deleted", + "type_info": "Bool" } ], "parameters": { @@ -33,8 +38,9 @@ false, true, false, + false, false ] }, - "hash": "5385ba9531992b91670e52b5332af1f09069e1d6d168f9e93b729cf964e97c35" + "hash": "8019c47351303c392784405ac53a46c9ad10015d4afd5bba97d21eff71b12436" } diff --git a/.sqlx/query-89ebb8b413db2c4da15adff8a09d04d5849c3990f0965de479b76630317f8a6e.json b/.sqlx/query-89ebb8b413db2c4da15adff8a09d04d5849c3990f0965de479b76630317f8a6e.json deleted file mode 100644 index d24766f..0000000 --- a/.sqlx/query-89ebb8b413db2c4da15adff8a09d04d5849c3990f0965de479b76630317f8a6e.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "INSERT INTO cqrs_inventory_store_query (\n version, name, address, store_id, owner\n ) VALUES (\n $1, $2, $3, $4, $5\n );", - "describe": { - "columns": [], - "parameters": { - "Left": [ - "Int8", - "Text", - "Text", - "Uuid", - "Uuid" - ] - }, - "nullable": [] - }, - "hash": "89ebb8b413db2c4da15adff8a09d04d5849c3990f0965de479b76630317f8a6e" -} 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 6300cc1..279c44c 100644 --- a/src/inventory/adapters/output/db/postgres/store_name_exists.rs +++ b/src/inventory/adapters/output/db/postgres/store_name_exists.rs @@ -15,6 +15,8 @@ impl StoreNameExistsDBPort for InventoryDBPostgresAdapter { FROM cqrs_inventory_store_query WHERE name = $1 + AND + deleted = false );", s.name(), ) @@ -64,6 +66,16 @@ mod tests { // state exists assert!(db.store_name_exists(&store).await.unwrap()); + // Set store.deleted = true; now db.store_id_exists must return false + sqlx::query!( + "UPDATE cqrs_inventory_store_query SET deleted = true WHERE store_id = $1;", + store.store_id() + ) + .execute(&db.pool) + .await + .unwrap(); + assert!(!db.store_name_exists(&store).await.unwrap()); + settings.drop_db().await; } }