diff options
| author | Sébastien Dailly <sebastien@dailly.me> | 2026-11-19 09:57:49 +0100 |
|---|---|---|
| committer | Sébastien Dailly <sebastien@dailly.me> | 2026-11-19 09:57:49 +0100 |
| commit | e1bf7686f408b52a870d4ed4f3c565dbbcc3954f (patch) | |
| tree | ee7e156032cc0c43ca10879051e64c3dfeab1515 /lib/query/tests | |
| parent | a9628fda0fc027c54b5ed5313a0c41731d79e41f (diff) | |
Management of lists in the settings
Diffstat (limited to 'lib/query/tests')
| -rw-r--r-- | lib/query/tests/create.t | 74 |
1 files changed, 74 insertions, 0 deletions
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" <<EOF + > { + > "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" <<EOF + > { + > "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") ) |
