diff options
| author | Sébastien Dailly <sebastien@dailly.me> | 2026-03-30 17:56:42 +0200 |
|---|---|---|
| committer | Sébastien Dailly <sebastien@dailly.me> | 2026-04-01 09:49:08 +0200 |
| commit | 4af7d2f6ff8b38365c97a89c295710f5ed3266f5 (patch) | |
| tree | 8b641d4992eac896223c5169a8b7301205685d85 /lib/query/tests/insert.t | |
| parent | 830e7c5d27d161b91402414e6ecd49f1ed818bfb (diff) | |
Manage insertion for multireferences fields
Diffstat (limited to 'lib/query/tests/insert.t')
| -rw-r--r-- | lib/query/tests/insert.t | 203 |
1 files changed, 194 insertions, 9 deletions
diff --git a/lib/query/tests/insert.t b/lib/query/tests/insert.t index 236bb97..af74436 100644 --- a/lib/query/tests/insert.t +++ b/lib/query/tests/insert.t @@ -110,7 +110,8 @@ Any value can be omitted and will be replaced by the default value: {"year":null} If the field is "required" the value is still inserted: the requirement feature -is only functionnal; this shall not block the creation of the content. +is only functionnal; this shall not block the creation of the content in the +database. $ tests -insert <<EOF > { @@ -155,14 +156,6 @@ A subcontent is linked to the parent: > "label": {}, > "type": "integer" > }, - > { - > "name": "ref", - > "label": {}, - > "type": { - > "content": "referential", - > "multivaluated": true - > } - > } > ] > } > ], @@ -211,3 +204,195 @@ A subcontent is linked to the parent: {"idx":2} details:3 {"comment":"lorem 2","parent":2} + +In this syntax, external references are declared inside the feature referencing +them. + + $ tests -insert <<EOF + > { + > "content": [ + > { + > "id": "referential", + > "section": [ + > { + > "field": [ + > { + > "name": "description", + > "label": {}, + > "type": "text" + > }, + > ] + > } + > ], + > "values": [ + > {"description": "id2"}, + > ] + > }, + > { + > "id": "entity", + > "section": [ + > { + > "field": [ + > { + > "name": "idx", + > "label": {}, + > "type": "integer" + > }, + > { + > "name": "comment", + > "label": {}, + > "type": { + > "content": "referential", + > "multivaluated": false + > } + > } + > ] + > } + > ], + > "values": [ + > { + > "idx": 1, + > "comment": {"description": "id1"}, + > + > }, + > ] + > } + > ] + > } + > EOF + referential:2 + {"description":"id2"} + entity:1 + {"idx":1,"comment":1} + +Four contents are created for the type referential here: +- Two as contents linked referenced by the content "entity" (ids 1 and 2). +- Two as contents not referenced at all (ids 3 and 4). + + $ tests -insert <<EOF + > { + > "content": [ + > { + > "id": "referential", + > "section": [ + > { + > "field": [ + > { + > "name": "description", + > "label": {}, + > "type": "text" + > }, + > ] + > } + > ], + > "values": [ + > {"description": "id3"}, + > {"description": "id4"} + > ] + > }, + > { + > "id": "entity", + > "section": [ + > { + > "field": [ + > { + > "name": "idx", + > "label": {}, + > "type": "integer" + > }, + > { + > "name": "comment", + > "label": {}, + > "type": { + > "content": "referential", + > "multivaluated": true + > } + > } + > ] + > } + > ], + > "values": [ + > { + > "idx": 1, + > "comment": [ + > {"description": "id1"}, + > {"description": "id2"} + > ] + > }, + > ] + > } + > ] + > } + > EOF + referential:3 + {"description":"id3"} + referential:4 + {"description":"id4"} + entity:1 + {"idx":1} + entity:1 + {"comment":1} + entity:1 + {"comment":2} + +Subcontent are also managed in the same way. + + $ tests -insert <<EOF + > { + > "content": [ + > { + > "id": "entity", + > "section": [ + > { + > "field": [ ] + > } + > ], + > "subcontent": [ + > { + > "id": "details", + > "section": [ + > { + > "field": [ + > { + > "name": "reference", + > "label": {}, + > "type": { + > "content": "referential", + > "multivaluated": true + > } + > } + > ] + > } + > ], + > } + > ], + > "values": [ + > { + > "idx": 1, + > "details": [ + > { + > // Create two references here, the counter for the non-linked + > // reference is raised to 3 + > "reference": [ {}, {} ] + > } + > ] + > }, + > ] + > }, + > { + > "id": "referential", + > "values": [ {} ] + > }, + > ] + > } + > EOF + entity:1 + {} + details:1 + {"parent":1} + details:1 + {"reference":1} + details:1 + {"reference":2} + referential:3 + {} |
