Skip to content
This repository was archived by the owner on Dec 13, 2023. It is now read-only.

Commit f00a149

Browse files
Simran-Bnerpaula
andauthored
Add remark that keepNull: false does not affect attributes in arrays (#1418)
* Add remark that keepNull: false does not affect attributes in arrays * Update examples for 3.10,3.11,3.12 in keepNull-nested-objects at 2023-06-26T09:45:44+00:00 --------- Co-authored-by: Paula Mihu <[email protected]> Co-authored-by: arangodb-release-bot <[email protected]>
1 parent 9219cf0 commit f00a149

File tree

1,110 files changed

+104102
-103666
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,110 files changed

+104102
-103666
lines changed

3.10/appendix-references-collection-object.md

+10-7
Original file line numberDiff line numberDiff line change
@@ -990,8 +990,9 @@ used to specify the following options:
990990
- `keepNull`: The optional `keepNull` parameter can be used to modify
991991
the behavior when handling `null` values. Normally, `null` values
992992
are stored in the database. By setting the `keepNull` parameter to
993-
`false`, this behavior can be changed so that all attributes in
994-
`data` with `null` values will be removed from the target document.
993+
`false`, this behavior can be changed so that top-level attributes and
994+
sub-attributes in `data` with `null` values are removed from the target
995+
document (but not attributes of objects that are nested inside of arrays).
995996
This option controls the update-insert behavior only.
996997
- `mergeObjects`: Controls whether objects (not arrays) will be
997998
merged if present in both the existing and the patch document. If
@@ -1456,8 +1457,9 @@ an object:
14561457
- `keepNull`: The optional `keepNull` parameter can be used to modify
14571458
the behavior when handling `null` values. Normally, `null` values
14581459
are stored in the database. By setting the `keepNull` parameter to
1459-
`false`, this behavior can be changed so that all attributes in
1460-
`data` with `null` values will be removed from the target document.
1460+
`false`, this behavior can be changed so that top-level attributes and
1461+
sub-attributes in `data` with `null` values are removed from the target
1462+
document (but not attributes of objects that are nested inside of arrays).
14611463
- `mergeObjects`: Controls whether objects (not arrays) will be
14621464
merged if present in both the existing and the patch document. If
14631465
set to `false`, the value in the patch document will overwrite the
@@ -1530,7 +1532,7 @@ Use a document identifier:
15301532
{% endarangoshexample %}
15311533
{% include arangoshexample.html id=examplevar script=script result=result %}
15321534

1533-
Use the `keepNull` parameter to remove attributes with null values:
1535+
Use the `keepNull` parameter to remove attributes with `null` values:
15341536

15351537
{% arangoshexample examplevar="examplevar" script="script" result="result" %}
15361538
@startDocuBlockInline documentsCollection_UpdateHandleKeepNull
@@ -1586,8 +1588,9 @@ The document meta-attributes `_id`, `_key` and `_rev` cannot be updated.
15861588
The optional `keepNull` parameter can be used to modify the behavior when
15871589
handling `null` values. Normally, `null` values are stored in the
15881590
database. By setting the `keepNull` parameter to `false`, this behavior
1589-
can be changed so that all attributes in `data` with `null` values will
1590-
be removed from the target document.
1591+
can be changed so that top-level attributes and sub-attributes in `data` with
1592+
`null` values are removed from the target document (but not attributes of
1593+
objects that are nested inside of arrays).
15911594

15921595
The optional `waitForSync` parameter can be used to force synchronization
15931596
of the document replacement operation to disk even in case that the

3.10/appendix-references-dbobject.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -809,8 +809,9 @@ Updates an existing document with additional boolean `options` passed via an obj
809809
- `keepNull`: The optional `keepNull` parameter can be used to modify
810810
the behavior when handling `null` values. Normally, `null` values
811811
are stored in the database. By setting the `keepNull` parameter to
812-
`false`, this behavior can be changed so that all attributes in
813-
`data` with `null` values will be removed from the target document.
812+
`false`, this behavior can be changed so that top-level attributes and
813+
sub-attributes in `data` with `null` values are removed from the target
814+
document (but not attributes of objects that are nested inside of arrays).
814815
- `mergeObjects`: Controls whether objects (not arrays) will be
815816
merged if present in both the existing and the patch document. If
816817
set to `false`, the value in the patch document will overwrite the

3.10/aql/operations-update.md

+9-4
Original file line numberDiff line numberDiff line change
@@ -269,10 +269,11 @@ to change them are ignored and not considered errors.
269269

270270
### `keepNull`
271271

272-
When updating an attribute to the `null` value, ArangoDB does not remove the attribute
273-
from the document but stores this `null` value. To remove attributes in an update
274-
operation, set them to `null` and set the `keepNull` option to `false`. This removes
275-
the attributes you specify but not any previously stored attributes with the `null` value:
272+
When updating an attribute to the `null` value, ArangoDB does not remove the
273+
attribute from the document but stores this `null` value. To remove attributes
274+
in an update operation, set them to `null` and set the `keepNull` option to
275+
`false`. This removes the attributes you specify but not any previously stored
276+
attributes with the `null` value:
276277

277278
```aql
278279
FOR u IN users
@@ -283,6 +284,10 @@ FOR u IN users
283284
The above query removes the `notNeeded` attribute from the documents and updates
284285
the `foobar` attribute normally.
285286

287+
Only top-level attributes and sub-attributes can be removed this way
288+
(e.g. `{ attr: { sub: null } }`) but not attributes of objects that are nested
289+
inside of arrays (e.g. `{ attr: [ { nested: null } ] }`).
290+
286291
### `mergeObjects`
287292

288293
The option `mergeObjects` controls whether object contents are

3.10/aql/operations-upsert.md

+30-5
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,15 @@ Syntax
1919

2020
The syntax for upsert and repsert operations is:
2121

22-
<pre><code>UPSERT <em>searchExpression</em> INSERT <em>insertExpression</em> UPDATE <em>updateExpression</em> IN <em>collection</em>
23-
UPSERT <em>searchExpression</em> INSERT <em>insertExpression</em> REPLACE <em>updateExpression</em> IN <em>collection</em></code></pre>
22+
<pre><code>UPSERT <em>searchExpression</em>
23+
INSERT <em>insertExpression</em>
24+
UPDATE <em>updateExpression</em>
25+
IN <em>collection</em></code></pre>
26+
27+
<pre><code>UPSERT <em>searchExpression</em>
28+
INSERT <em>insertExpression</em>
29+
REPLACE <em>updateExpression</em>
30+
IN <em>collection</em></code></pre>
2431

2532
Both variants can optionally end with an `OPTIONS { … }` clause.
2633

@@ -68,9 +75,27 @@ when trying to violate unique key constraints.
6875

6976
### `keepNull`
7077

71-
When updating or replacing an attribute with a null value, ArangoDB will not remove the
72-
attribute from the document but store a null value for it. To get rid of attributes in
73-
an upsert operation, set them to null and provide the `keepNull` option.
78+
When updating an attribute to the `null` value, ArangoDB does not remove the
79+
attribute from the document but stores this `null` value. To remove attributes
80+
in an update operation, set them to `null` and set the `keepNull` option to
81+
`false`. This removes the attributes you specify but not any previously stored
82+
attributes with the `null` value:
83+
84+
```aql
85+
UPSERT { _key: "mary" }
86+
INSERT { _key: "mary", name: "Mary", notNeeded: 123 }
87+
UPDATE { foobar: true, notNeeded: null }
88+
IN users OPTIONS { keepNull: false }
89+
```
90+
91+
If no document with the key `mary` exists, the above query creates such a user
92+
document with a `notNeeded` attribute. If it exists already, it removes the
93+
`notNeeded` attribute from the document and updates the `foobar` attribute
94+
normally.
95+
96+
Only top-level attributes and sub-attributes can be removed this way
97+
(e.g. `{ attr: { sub: null } }`) but not attributes of objects that are nested
98+
inside of arrays (e.g. `{ attr: [ { nested: null } ] }`).
7499

75100
### `mergeObjects`
76101

3.10/generated/Examples/001_collectionAll.generated

+10-10
Original file line numberDiff line numberDiff line change
@@ -2,62 +2,62 @@ arangosh&gt; db.five.insert({ <span class="hljs-attr">name</span> : <span class=
22
{
33
<span class="hljs-string">&quot;_id&quot;</span> : <span class="hljs-string">&quot;five/104&quot;</span>,
44
<span class="hljs-string">&quot;_key&quot;</span> : <span class="hljs-string">&quot;104&quot;</span>,
5-
<span class="hljs-string">&quot;_rev&quot;</span> : <span class="hljs-string">&quot;_gM2ZmBW---&quot;</span>
5+
<span class="hljs-string">&quot;_rev&quot;</span> : <span class="hljs-string">&quot;_gNZFFvK---&quot;</span>
66
}
77
arangosh&gt; db.five.insert({ <span class="hljs-attr">name</span> : <span class="hljs-string">&quot;two&quot;</span> });
88
{
99
<span class="hljs-string">&quot;_id&quot;</span> : <span class="hljs-string">&quot;five/106&quot;</span>,
1010
<span class="hljs-string">&quot;_key&quot;</span> : <span class="hljs-string">&quot;106&quot;</span>,
11-
<span class="hljs-string">&quot;_rev&quot;</span> : <span class="hljs-string">&quot;_gM2ZmBa---&quot;</span>
11+
<span class="hljs-string">&quot;_rev&quot;</span> : <span class="hljs-string">&quot;_gNZFFvO---&quot;</span>
1212
}
1313
arangosh&gt; db.five.insert({ <span class="hljs-attr">name</span> : <span class="hljs-string">&quot;three&quot;</span> });
1414
{
1515
<span class="hljs-string">&quot;_id&quot;</span> : <span class="hljs-string">&quot;five/108&quot;</span>,
1616
<span class="hljs-string">&quot;_key&quot;</span> : <span class="hljs-string">&quot;108&quot;</span>,
17-
<span class="hljs-string">&quot;_rev&quot;</span> : <span class="hljs-string">&quot;_gM2ZmBa--_&quot;</span>
17+
<span class="hljs-string">&quot;_rev&quot;</span> : <span class="hljs-string">&quot;_gNZFFvO--_&quot;</span>
1818
}
1919
arangosh&gt; db.five.insert({ <span class="hljs-attr">name</span> : <span class="hljs-string">&quot;four&quot;</span> });
2020
{
2121
<span class="hljs-string">&quot;_id&quot;</span> : <span class="hljs-string">&quot;five/110&quot;</span>,
2222
<span class="hljs-string">&quot;_key&quot;</span> : <span class="hljs-string">&quot;110&quot;</span>,
23-
<span class="hljs-string">&quot;_rev&quot;</span> : <span class="hljs-string">&quot;_gM2ZmBe---&quot;</span>
23+
<span class="hljs-string">&quot;_rev&quot;</span> : <span class="hljs-string">&quot;_gNZFFvS---&quot;</span>
2424
}
2525
arangosh&gt; db.five.insert({ <span class="hljs-attr">name</span> : <span class="hljs-string">&quot;five&quot;</span> });
2626
{
2727
<span class="hljs-string">&quot;_id&quot;</span> : <span class="hljs-string">&quot;five/112&quot;</span>,
2828
<span class="hljs-string">&quot;_key&quot;</span> : <span class="hljs-string">&quot;112&quot;</span>,
29-
<span class="hljs-string">&quot;_rev&quot;</span> : <span class="hljs-string">&quot;_gM2ZmBe--_&quot;</span>
29+
<span class="hljs-string">&quot;_rev&quot;</span> : <span class="hljs-string">&quot;_gNZFFvS--_&quot;</span>
3030
}
3131
arangosh&gt; db.five.all().toArray();
3232
[
3333
{
3434
<span class="hljs-string">&quot;_key&quot;</span> : <span class="hljs-string">&quot;104&quot;</span>,
3535
<span class="hljs-string">&quot;_id&quot;</span> : <span class="hljs-string">&quot;five/104&quot;</span>,
36-
<span class="hljs-string">&quot;_rev&quot;</span> : <span class="hljs-string">&quot;_gM2ZmBW---&quot;</span>,
36+
<span class="hljs-string">&quot;_rev&quot;</span> : <span class="hljs-string">&quot;_gNZFFvK---&quot;</span>,
3737
<span class="hljs-string">&quot;name&quot;</span> : <span class="hljs-string">&quot;one&quot;</span>
3838
},
3939
{
4040
<span class="hljs-string">&quot;_key&quot;</span> : <span class="hljs-string">&quot;106&quot;</span>,
4141
<span class="hljs-string">&quot;_id&quot;</span> : <span class="hljs-string">&quot;five/106&quot;</span>,
42-
<span class="hljs-string">&quot;_rev&quot;</span> : <span class="hljs-string">&quot;_gM2ZmBa---&quot;</span>,
42+
<span class="hljs-string">&quot;_rev&quot;</span> : <span class="hljs-string">&quot;_gNZFFvO---&quot;</span>,
4343
<span class="hljs-string">&quot;name&quot;</span> : <span class="hljs-string">&quot;two&quot;</span>
4444
},
4545
{
4646
<span class="hljs-string">&quot;_key&quot;</span> : <span class="hljs-string">&quot;108&quot;</span>,
4747
<span class="hljs-string">&quot;_id&quot;</span> : <span class="hljs-string">&quot;five/108&quot;</span>,
48-
<span class="hljs-string">&quot;_rev&quot;</span> : <span class="hljs-string">&quot;_gM2ZmBa--_&quot;</span>,
48+
<span class="hljs-string">&quot;_rev&quot;</span> : <span class="hljs-string">&quot;_gNZFFvO--_&quot;</span>,
4949
<span class="hljs-string">&quot;name&quot;</span> : <span class="hljs-string">&quot;three&quot;</span>
5050
},
5151
{
5252
<span class="hljs-string">&quot;_key&quot;</span> : <span class="hljs-string">&quot;110&quot;</span>,
5353
<span class="hljs-string">&quot;_id&quot;</span> : <span class="hljs-string">&quot;five/110&quot;</span>,
54-
<span class="hljs-string">&quot;_rev&quot;</span> : <span class="hljs-string">&quot;_gM2ZmBe---&quot;</span>,
54+
<span class="hljs-string">&quot;_rev&quot;</span> : <span class="hljs-string">&quot;_gNZFFvS---&quot;</span>,
5555
<span class="hljs-string">&quot;name&quot;</span> : <span class="hljs-string">&quot;four&quot;</span>
5656
},
5757
{
5858
<span class="hljs-string">&quot;_key&quot;</span> : <span class="hljs-string">&quot;112&quot;</span>,
5959
<span class="hljs-string">&quot;_id&quot;</span> : <span class="hljs-string">&quot;five/112&quot;</span>,
60-
<span class="hljs-string">&quot;_rev&quot;</span> : <span class="hljs-string">&quot;_gM2ZmBe--_&quot;</span>,
60+
<span class="hljs-string">&quot;_rev&quot;</span> : <span class="hljs-string">&quot;_gNZFFvS--_&quot;</span>,
6161
<span class="hljs-string">&quot;name&quot;</span> : <span class="hljs-string">&quot;five&quot;</span>
6262
}
6363
]

3.10/generated/Examples/002_collectionAllNext.generated

+7-7
Original file line numberDiff line numberDiff line change
@@ -2,44 +2,44 @@ arangosh&gt; db.five.insert({ <span class="hljs-attr">name</span> : <span class=
22
{
33
<span class="hljs-string">&quot;_id&quot;</span> : <span class="hljs-string">&quot;five/124&quot;</span>,
44
<span class="hljs-string">&quot;_key&quot;</span> : <span class="hljs-string">&quot;124&quot;</span>,
5-
<span class="hljs-string">&quot;_rev&quot;</span> : <span class="hljs-string">&quot;_gM2ZmDG--_&quot;</span>
5+
<span class="hljs-string">&quot;_rev&quot;</span> : <span class="hljs-string">&quot;_gNZFFw6---&quot;</span>
66
}
77
arangosh&gt; db.five.insert({ <span class="hljs-attr">name</span> : <span class="hljs-string">&quot;two&quot;</span> });
88
{
99
<span class="hljs-string">&quot;_id&quot;</span> : <span class="hljs-string">&quot;five/126&quot;</span>,
1010
<span class="hljs-string">&quot;_key&quot;</span> : <span class="hljs-string">&quot;126&quot;</span>,
11-
<span class="hljs-string">&quot;_rev&quot;</span> : <span class="hljs-string">&quot;_gM2ZmDK---&quot;</span>
11+
<span class="hljs-string">&quot;_rev&quot;</span> : <span class="hljs-string">&quot;_gNZFFw6--_&quot;</span>
1212
}
1313
arangosh&gt; db.five.insert({ <span class="hljs-attr">name</span> : <span class="hljs-string">&quot;three&quot;</span> });
1414
{
1515
<span class="hljs-string">&quot;_id&quot;</span> : <span class="hljs-string">&quot;five/128&quot;</span>,
1616
<span class="hljs-string">&quot;_key&quot;</span> : <span class="hljs-string">&quot;128&quot;</span>,
17-
<span class="hljs-string">&quot;_rev&quot;</span> : <span class="hljs-string">&quot;_gM2ZmDK--_&quot;</span>
17+
<span class="hljs-string">&quot;_rev&quot;</span> : <span class="hljs-string">&quot;_gNZFFx----&quot;</span>
1818
}
1919
arangosh&gt; db.five.insert({ <span class="hljs-attr">name</span> : <span class="hljs-string">&quot;four&quot;</span> });
2020
{
2121
<span class="hljs-string">&quot;_id&quot;</span> : <span class="hljs-string">&quot;five/130&quot;</span>,
2222
<span class="hljs-string">&quot;_key&quot;</span> : <span class="hljs-string">&quot;130&quot;</span>,
23-
<span class="hljs-string">&quot;_rev&quot;</span> : <span class="hljs-string">&quot;_gM2ZmDO---&quot;</span>
23+
<span class="hljs-string">&quot;_rev&quot;</span> : <span class="hljs-string">&quot;_gNZFFx---_&quot;</span>
2424
}
2525
arangosh&gt; db.five.insert({ <span class="hljs-attr">name</span> : <span class="hljs-string">&quot;five&quot;</span> });
2626
{
2727
<span class="hljs-string">&quot;_id&quot;</span> : <span class="hljs-string">&quot;five/132&quot;</span>,
2828
<span class="hljs-string">&quot;_key&quot;</span> : <span class="hljs-string">&quot;132&quot;</span>,
29-
<span class="hljs-string">&quot;_rev&quot;</span> : <span class="hljs-string">&quot;_gM2ZmDO--_&quot;</span>
29+
<span class="hljs-string">&quot;_rev&quot;</span> : <span class="hljs-string">&quot;_gNZFFxC---&quot;</span>
3030
}
3131
arangosh&gt; db.five.all().limit(<span class="hljs-number">2</span>).toArray();
3232
[
3333
{
3434
<span class="hljs-string">&quot;_key&quot;</span> : <span class="hljs-string">&quot;124&quot;</span>,
3535
<span class="hljs-string">&quot;_id&quot;</span> : <span class="hljs-string">&quot;five/124&quot;</span>,
36-
<span class="hljs-string">&quot;_rev&quot;</span> : <span class="hljs-string">&quot;_gM2ZmDG--_&quot;</span>,
36+
<span class="hljs-string">&quot;_rev&quot;</span> : <span class="hljs-string">&quot;_gNZFFw6---&quot;</span>,
3737
<span class="hljs-string">&quot;name&quot;</span> : <span class="hljs-string">&quot;one&quot;</span>
3838
},
3939
{
4040
<span class="hljs-string">&quot;_key&quot;</span> : <span class="hljs-string">&quot;126&quot;</span>,
4141
<span class="hljs-string">&quot;_id&quot;</span> : <span class="hljs-string">&quot;five/126&quot;</span>,
42-
<span class="hljs-string">&quot;_rev&quot;</span> : <span class="hljs-string">&quot;_gM2ZmDK---&quot;</span>,
42+
<span class="hljs-string">&quot;_rev&quot;</span> : <span class="hljs-string">&quot;_gNZFFw6--_&quot;</span>,
4343
<span class="hljs-string">&quot;name&quot;</span> : <span class="hljs-string">&quot;two&quot;</span>
4444
}
4545
]

0 commit comments

Comments
 (0)