8000 updated changes · lethalbrains/arangodb@316f2bd · GitHub
[go: up one dir, main page]

Skip to content

Commit 316f2bd

Browse files
committed
updated changes
1 parent 49c39f6 commit 316f2bd

File tree

3 files changed

+88
-27
lines changed

3 files changed

+88
-27
lines changed

Documentation/Books/AQL/Functions/TypeCast.mdpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,30 +44,30 @@ not not 1 // true
4444
- Strings are converted to their numeric equivalent if the string contains a
4545
valid representation of a number. Whitespace at the start and end of the string
4646
is allowed. String values that do not contain any valid representation of a number
47-
will be converted to *null*.
47+
will be converted to the number *0*.
4848
- An empty array is converted to *0*, an array with one member is converted into the
4949
result of `TO_NUMBER()` for its sole member. An array with two or more members is
50-
converted to *null*.
51-
- An object / document is converted to *null*.
50+
converted to the number *0*.
51+
- An object / document is converted to the number *0*.
5252

5353
An unary plus will also try to cast to a number, but `TO_NUMBER()` is the preferred way:
5454
```js
5555
+'5' // 5
5656
+[8] // 8
57-
+[8,9] // null
58-
+{} // null
57+
+[8,9] // 0
58+
+{} // 0
5959
```
60-
An unary minus works likewise, except that a numeric value is also negated:
60+
A unary minus works likewise, except that a numeric value is also negated:
6161
```js
6262
-'5' // -5
6363
-[8] // -8
64-
-[8,9] // null
65-
-{} // null
64+
-[8,9] // 0
65+
-{} // 0
6666
```
6767

6868
- *TO_STRING(value)*: Takes an input *value* of any type and converts it
6969
into a string value as follows:
70-
- *null* is converted to the string *"null"*
70+
- *null* is converted to the the empty string *""*
7171
- *false* is converted to the string *"false"*, *true* to the string *"true"*
7272
- Numbers are converted to their string representations. This can also be a
7373
scientific notation: `TO_STRING(0.0000002) // "2e-7"`

Documentation/Books/AQL/Operators.mdpp

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -198,42 +198,39 @@ Some example arithmetic operations:
198198
-15
199199
+9.99
200200

201-
The arithmetic operators accept operands of any type. This behavior has changed in
202-
ArangoDB 2.3. Passing non-numeric values to an arithmetic operator is now allow.
203-
Any non-numeric operands will be casted to numbers implicitly by the operator,
204-
without making the query abort.
201+
The arithmetic operators accept operands of any type. Passing non-numeric values to an
202+
arithmetic operator will cast the operands to numbers using the type casting rules
203+
applied by the `TO_NUMBER` function:
205204

206-
The *conversion to a numeric value* works as follows:
207205
- `null` will be converted to `0`
208206
- `false` will be converted to `0`, true will be converted to `1`
209-
- a valid numeric value remains unchanged, but NaN and Infinity will be converted to `null`
207+
- a valid numeric value remains unchanged, but NaN and Infinity will be converted to `0`
210208
- string values are converted to a number if they contain a valid string representation
211209
of a number. Any whitespace at the start or the end of the string is ignored. Strings
212-
with any other contents are converted to `null`
210+
with any other contents are converted to the number `0`
213211
- an empty array is converted to `0`, an array with one member is converted to the numeric
214-
representation of its sole member. Arrays with more members are converted
215-
to `null`
216-
- objects / documents are converted to `null`
212+
representation of its sole member. Arrays with more members are converted to the number
213+
`0`.
214+
- objects / documents are converted to the number `0`.
217215

218-
If the conversion to a number produces a value of `null` for one of the operands,
219-
the result of the whole arithmetic operation will also be `null`. An arithmetic operation
220-
that produces an invalid value, such as `1 / 0` will also produce a value of `null`.
216+
An arithmetic operation that produces an invalid value, such as `1 / 0` will also produce
217+
a result value of `0`.
221218

222219
Here are a few examples:
223220

224-
1 + "a" // null
221+
1 + "a" // 1
225222
1 + "99" // 100
226223
1 + null // 1
227224
null + 1 // 1
228225
3 + [ ] // 3
229226
24 + [ 2 ] // 26
230-
24 + [ 2, 4 ] // null
227+
24 + [ 2, 4 ] // 0
231228
25 - null // 25
232229
17 - true // 16
233-
23 * { } // null
230+
23 * { } // 0
234231
5 * [ 7 ] // 35
235232
24 / "12" // 2
236-
1 / 0 // null
233+
1 / 0 // 0
237234

238235

239236
!SUBSUBSECTION Ternary operator

Documentation/Books/Users/ReleaseNotes/UpgradingChanges30.mdpp

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,74 @@ by the drop operation now.
3939

4040
!SECTION AQL
4141

42+
!SUBSECTION Typecasting functions
43+
44+
The type casting applied by the `TO_NUMBER()` AQL function has changed as follows:
45+
- string values that do not contain a valid numeric value are now converted to the number
46+
`0`. In previous versions of ArangoDB such string values were converted to the value
47+
`null`.
48+
- array values with more than 1 member are now converted to the number `0`. In previous
49+
versions of ArangoDB such arrays were converted to the value `null`.
50+
- objects / documents are now converted to the number `0`. In previous versions of ArangoDB
51+
objects / documents were converted to the value `null`.
52+
53+
Additionally, the `TO_STRING()` AQL function now converts `null` values into an empty string
54+
(`""`) instead of the string `"null"`.
55+
56+
57+
!SUBSECTION Arithmetic operators
58+
59+
As the arithmetic operations in AQL implicitly convert their operands to numeric values using
60+
`TO_NUMBER()`, their casting behavior has also changed as described above.
61+
62+
Some examples of the changed behavior:
63+
64+
- `"foo" + 1` produces `1` now. In previous versions this produced `null`.
65+
- `[ 1, 2 ] + 1` produces `1`. In previous versions this produced `null`.
66+
- `1 + "foo" + 1´ produces `2` now. In previous version this produced `1`.
67+
68+
!SUBSECTION Keywords
69+
4270
`LIKE` is now a keyword in AQL. Using `LIKE` in either case as an attribute or collection
4371
name in AQL queries now requires quoting.
4472

45-
The AQL optimizer rule "merge-traversal-filter" was renamed to "optimize-traversals".
73+
!SUBSECTION Subqueries
74+
75+
Queries that contain Subqueries that contain data-modification operations such as `INSERT`,
76+
`UPDATE`, `REPLACE`, `UPSERT` or `REMOVE` will now refuse to execute if the collection
77+
affected by the subquery's data-modification operation is read-accessed in an outer scope
78+
of the query.
79+
80+
For example, the following query will refuse to execute as the collection `myCollection`
81+
is modified in the subquery but also read-accessed in the outer scope:
82+
83+
```
84+
FOR doc IN myCollection
85+
LET changes = (
86+
FOR what IN myCollection
87+
FILTER what.value == 1
88+
REMOVE what IN myCollection
89+
)
90+
RETURN doc
91+
```
92+
93+
It is still possible to write to collections from which data is read in the same query,
94+
e.g.
95+
96+
```
97+
FOR doc IN myCollection
98+
FILTER doc.value == 1
99+
REMOVE doc IN myCollection
100+
```
101+
102+
and to modify data in different collection via subqueries.
103+
104+
105+
!SUBSECTION Other changes
106+
107+
The AQL optimizer rule "merge-traversal-filter" that already existed in 3.0 was renamed to
108+
"optimize-traversals". This should be of no relevance to client applications except if
109+
they programatically look for applied optimizer rules in the explain out of AQL queries.
46110

47111

48112
!SECTION Command-line options

0 commit comments

Comments
 (0)
0