8000 Improve statements about AQL names (#1422) · arangodb/docs@06a676d · GitHub
[go: up one dir, main page]

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

Commit 06a676d

Browse files
authored
Improve statements about AQL names (#1422)
1 parent 5fba360 commit 06a676d

File tree

3 files changed

+84
-42
lines changed

3 files changed

+84
-42
lines changed

3.10/aql/fundamentals-syntax.md

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,22 @@ FOR f IN `filter`
246246
`sort` is a string literal in quote marks in this alternative and does thus not
247247
conflict with the reserved keyword.
248248

249+
Quoting with ticks is also required if certain characters such as
250+
hyphen minus (`-`) are contained in a name, namely if they are used for
251+
[operators](operators.html) in AQL:
252+
253+
```aql
254+
LET `my-var` = 42
255+
```
256+
257+
### Collection names
258+
259+
You can typically use collection names in queries as they are. If a collection
260+
happens to have the same name as a keyword, the name must be enclosed in
261+
backticks or forward ticks.
262+
249263
Quoting with ticks is also required if special characters such as
250-
hyphen minus (`-`) are contained in a name:
264+
hyphen minus (`-`) are contained in a collection name:
251265

252266
```aql
253267
FOR doc IN `my-coll`
@@ -261,18 +275,9 @@ refer to the collection correctly.
261275
Note that quoting the name with `"` or `'` is not possible for collections as
262276
they cannot be string literals in quote marks.
263277

264-
### Collection names
265-
266-
Collection names can be used in queries as they are. If a collection happens to
267-
have the same name as a keyword, the name must be enclosed in backticks or
268-
forward ticks.
269-
270278
For information about the naming constraints for collections, see
271279
[Collection names](../data-modeling-collections.html#collection-names).
272280

273-
AQL currently has a limit of up to 256 collections used in one AQL query.
274-
This limit applies to the sum of all involved document and edge collections.
275-
276281
### Attribute names
277282

278283
When referring to attributes of documents from a collection, the fully qualified
@@ -296,10 +301,9 @@ respectively).
296301

297302
### Variable names
298303

299-
AQL allows the user to assign values to additional variables in a query. All
300-
variables that are assigned a value must have a name that is unique within the
301-
context of the query. Variable names must be different from the names of any
302-
collection name used in the same query.
304+
AQL allows you to assign values to additional variables in a query.
305+
All variables that are assigned a value must have a name that is unique within
306+
the context of the query.
303307

304308
```aql
305309
FOR u IN users
@@ -311,6 +315,16 @@ In the above query, `users` is a collection name, and both `u` and `friends` are
311315
variable names. This is because the `FOR` and `LET` operations need target
312316
variables to store their intermediate results.
313317

318+
Variable names should be different from the names of any collection name used in
319+
the same query to avoid shadowing, which can render a collection with the same
320+
name inaccessible in the query after the variable assignment:
321+
322+
```aql
323+
LET users = []
324+
FOR u IN users // iterates over the "users" variable, not the "users" collection
325+
RETURN u
326+
```
327+
314328
Allowed characters in variable names are the letters `a` to `z` (both in lower
315329
and upper case), the numbers `0` to `9`, the underscore (`_`) symbol and the
316330
dollar (`$`) sign. A variable name must not start with a number. If a variable

3.11/aql/fundamentals-syntax.md

Lines changed: 28 additions & 14 deletions
6D47 336
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,22 @@ FOR f IN `filter`
246246
`sort` is a string literal in quote marks in this alternative and does thus not
247247
conflict with the reserved keyword.
248248

249+
Quoting with ticks is also required if certain characters such as
250+
hyphen minus (`-`) are contained in a name, namely if they are used for
251+
[operators](operators.html) in AQL:
252+
253+
```aql
254+
LET `my-var` = 42
255+
```
256+
257+
### Collection names
258+
259+
You can typically use collection names in queries as they are. If a collection
260+
happens to have the same name as a keyword, the name must be enclosed in
261+
backticks or forward ticks.
262+
249263
Quoting with ticks is also required if special characters such as
250-
hyphen minus (`-`) are contained in a name:
264+
hyphen minus (`-`) are contained in a collection name:
251265

252266
```aql
253267
FOR doc IN `my-coll`
@@ -275,18 +289,9 @@ naming constraints and is quoted with forward ticks.
275289
Note that quoting the name with `"` or `'` is not possible for collections as
276290
they cannot be string literals in quote marks.
277291

278-
### Collection names
279-
280-
Collection names can be used in queries as they are. If a collection happens to
281-
have the same name as a keyword, the name must be enclosed in backticks or
282-
forward ticks.
283-
284292
For information about the naming constraints for collections, see
285293
[Collection names](../data-modeling-collections.html#collection-names).
286294

287-
AQL currently has a limit of up to 256 collections used in one AQL query.
288-
This limit applies to the sum of all involved document and edge collections.
289-
290295
### Attribute names
291296

292297
When referring to attributes of documents from a collection, the fully qualified
@@ -310,10 +315,9 @@ respectively).
310315

311316
### Variable names
312317

313-
AQL allows the user to assign values to additional variables in a query. All
314-
variables that are assigned a value must have a name that is unique within the
315-
context of the query. Variable names must be different from the names of any
316-
collection name used in the same query.
318+
AQL allows you to assign values to additional variables in a query.
319+
All variables that are assigned a value must have a name that is unique within
320+
the context of the query.
317321

318322
```aql
319323
FOR u IN users
@@ -325,6 +329,16 @@ In the above query, `users` is a collection name, and both `u` and `friends` are
325329
variable names. This is because the `FOR` and `LET` operations need target
326330
variables to store their intermediate results.
327331

332+
Variable names should be different from the names of any collection name used in
333+
the same query to avoid shadowing, which can render a collection with the same
334+
name inaccessible in the query after the variable assignment:
335+
+
```aql
337+
LET users = []
338+
FOR u IN users // iterates over the "users" variable, not the "users" collection
339+
RETURN u
340+
```
341+
328342
Allowed characters in variable names are the letters `a` to `z` (both in lower
329343
and upper case), the numbers `0` to `9`, the underscore (`_`) symbol and the
330344
dollar (`$`) sign. A variable name must not start with a number. If a variable

3.12/aql/fundamentals-syntax.md

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,22 @@ FOR f IN `filter`
246246
`sort` is a string literal in quote marks in this alternative and does thus not
247247
conflict with the reserved keyword.
248248

249+
Quoting with ticks is also required if certain characters such as
250+
hyphen minus (`-`) are contained in a name, namely if they are used for
251+
[operators](operators.html) in AQL:
252+
253+
```aql
254+
LET `my-var` = 42
255+
```
256+
257+
### Collection names
258+
259+
You can typically use collection names in queries as they are. If a collection
260+
happens to have the same name as a keyword, the name must be enclosed in
261+
backticks or forward ticks.
262+
249263
Quoting with ticks is also required if special characters such as
250-
hyphen minus (`-`) are contained in a name:
264+
hyphen minus (`-`) are contained in a collection name:
251265

252266
```aql
253267
FOR doc IN `my-coll`
@@ -275,18 +289,9 @@ naming constraints and is quoted with forward ticks.
275289
Note that quoting the name with `"` or `'` is not possible for collections as
276290
they cannot be string literals in quote marks.
277291

278-
### Collection names
279-
280-
Collection names can be used in queries as they are. If a collection happens to
281-
have the same name as a keyword, the name must be enclosed in backticks or
282-
forward ticks.
283-
284292
For information about the naming constraints for collections, see
285293
[Collection names](../data-modeling-collections.html#collection-names).
286294

287-
AQL currently has a limit of up to 256 collections used in one AQL query.
288-
This limit applies to the sum of all involved document and edge collections.
289-
290295
### Attribute names
291296

292297
When referring to attributes of documents from a collection, the fully qualified
@@ -310,10 +315,9 @@ respectively).
310315

311316
### Variable names
312317

313-
AQL allows the user to assign values to additional variables in a query. All
314-
variables that are assigned a value must have a name that is unique within the
315-
context of the query. Variable names must be different from the names of any
316-
collection name used in the same query.
318+
AQL allows you to assign values to additional variables in a query.
319+
All variables that are assigned a value must have a name that is unique within
320+
the context of the query.
317321

318322
```aql
319323
FOR u IN users
@@ -325,6 +329,16 @@ In the above query, `users` is a collection name, and both `u` and `friends` are
325329
variable names. This is because the `FOR` and `LET` operations need target
326330
variables to store their intermediate results.
327331

332+
Variable names should be different from the names of any collection name used in
333+
the same query to avoid shadowing, which can render a collection with the same
334+
name inaccessible in the query after the variable assignment:
335+
336+
```aql
337+
LET users = []
338+
FOR u IN users // iterates over the "users" variable, not the "users" collection
339+
RETURN u
340+
```
341+
328342
Allowed characters in variable names are the letters `a` to `z` (both in lower
329343
and upper case), the numbers `0` to `9`, the underscore (`_`) symbol and the
330344
dollar (`$`) sign. A variable name must not start with a number. If a variable

0 commit comments

Comments
 (0)
0