From e1bf7686f408b52a870d4ed4f3c565dbbcc3954f Mon Sep 17 00:00:00 2001 From: Sébastien Dailly Date: Thu, 19 Nov 2026 09:57:49 +0100 Subject: Management of lists in the settings --- lib/query/tests/create.t | 74 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) (limited to 'lib/query/tests') diff --git a/lib/query/tests/create.t b/lib/query/tests/create.t index 38a4630..46e3940 100644 --- a/lib/query/tests/create.t +++ b/lib/query/tests/create.t @@ -149,3 +149,77 @@ table but a dedicated table is created: , FOREIGN KEY("parent") REFERENCES "entity"("id") , FOREIGN KEY("target") REFERENCES "user_type_list"("id") ) +A declared list gets its own table, holding an id. A reference field pointing +to a list is an integer column constrained by a foreign key to the list table: + + $ tests --schema "user_type_list" "entity" < { + > "list": [ + > { + > "id": "user_type_list", + > "source": "csv" + > } + > ], + > "content": [ + > { + > "id": "entity", + > "section": [ + > { + > "field": [ + > { + > "name": "user_type", + > "label": {}, + > "type": { "content": "user_type_list" } + > } + > ] + > } + > ] + > } + > ] + > } + > EOF + CREATE TABLE "user_type_list" + ( "id" INTEGER PRIMARY KEY ) + CREATE TABLE "entity" + ( "id" INTEGER PRIMARY KEY + , "user_type" INTEGER + , FOREIGN KEY("user_type") REFERENCES "user_type_list"("id") ) + +A multivaluated reference to a list gets the usual dedicated table, with the +target column referencing the list table: + + $ tests --schema "entity.user_type" < { + > "list": [ + > { + > "id": "user_type_list", + > "source": "csv" + > } + > ], + > "content": [ + > { + > "id": "entity", + > "section": [ + > { + > "field": [ + > { + > "name": "user_type", + > "label": {}, + > "type": { + > "content": "user_type_list", + > "multivaluated": true + > } + > } + > ] + > } + > ] + > } + > ] + > } + > EOF + CREATE TABLE "entity.user_type" + ( "id" INTEGER PRIMARY KEY + , "parent" INTEGER NOT NULL + , "target" INTEGER NOT NULL + , FOREIGN KEY("parent") REFERENCES "entity"("id") + , FOREIGN KEY("target") REFERENCES "user_type_list"("id") ) -- cgit v1.2.3