1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
Test the capacity to insert elements in the database according to a specific
schema.
The configuration is read on the standard input, and the name of the content to
populate is given as argument. Two rows are inserted per run, with a value
generated for each field from its type and the row number (see
[Common.provider_for]): text and integer fields get a value derived from the
field name, monovalued references point to the row of id 1, and multivalued
references get two values for the first row and one for the second.
A content without any field gets an empty row:
$ tests --insert "entity" <<EOF
> {
> "content": [
> {
> "id": "entity"
> }
> ]
> }
> EOF
entity:1
{}
entity:2
{}
Text and integer fields are filled with a generated value:
$ tests --insert "entity" <<EOF
> {
> "content": [
> {
> "id": "entity",
> "section": [
> {
> "field": [
> { "name": "name", "label": {}, "type": "text" },
> { "name": "year", "label": {}, "type": "integer" }
> ]
> }
> ]
> }
> ]
> }
> EOF
entity:1
{"name":"name-1","year":1}
entity:2
{"name":"name-2","year":2}
References are declared in the field type. A monovalued reference stores the
id of the target row in the content table, and each value of a multivalued
reference gets its own line, read back from the dedicated table:
$ tests --insert "entity" <<EOF
> {
> "list": [
> {
> "id": "country_list",
> "field": [
> { "name": "code", "label": {}, "type": "text" }
> ]
> }
> ],
> "content": [
> {
> "id": "entity",
> "section": [
> {
> "field": [
> { "name": "name", "label": {}, "type": "text" },
> { "name": "year", "label": {}, "type": "integer" },
> {
> "name": "country",
> "label": {},
> "type": { "content": "country_list" }
> },
> {
> "name": "aliases",
> "label": {},
> "type": { "content": "country_list", "multivaluated": true }
> }
> ]
> }
> ]
> }
> ]
> }
> EOF
entity:1
{"name":"name-1","year":1,"country":1}
entity:1
{"aliases":1}
entity:1
{"aliases":2}
entity:2
{"name":"name-2","year":2,"country":1}
entity:2
{"aliases":2}
|