From 2e01ecbe589d763ad8e6ae4900e96bfade5a5b3b Mon Sep 17 00:00:00 2001 From: Bernd Bestel Date: Wed, 16 Dec 2020 17:37:44 +0100 Subject: [PATCH] Enforce product nesting level also for the API --- migrations/0121.sql | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 migrations/0121.sql diff --git a/migrations/0121.sql b/migrations/0121.sql new file mode 100644 index 00000000..ff184239 --- /dev/null +++ b/migrations/0121.sql @@ -0,0 +1,10 @@ +CREATE TRIGGER enfore_product_nesting_level BEFORE UPDATE ON products +BEGIN + -- Currently only 1 level is supported + SELECT CASE WHEN(( + SELECT 1 + FROM products p + WHERE IFNULL(NEW.parent_product_id, '') != '' + AND IFNULL(parent_product_id, '') = NEW.id + ) NOTNULL) THEN RAISE(ABORT, "Unsupported product nesting level detected (currently only 1 level is supported)") END; +END;