Skip to content

Commit a71b9d4

Browse files
Add brittleness information to id()/elementId() functions (#1035)
1 parent 72e2eee commit a71b9d4

File tree

2 files changed

+18
-15
lines changed

2 files changed

+18
-15
lines changed

modules/ROOT/pages/clauses/order-by.adoc

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,9 @@ The nodes are returned, sorted by their internal ID.
114114
|===
115115

116116
[NOTE]
117-
====
118-
Keep in mind that Neo4j reuses its internal IDs when nodes and relationships are deleted.
119-
This means that applications using, and relying on, internal Neo4j IDs, are brittle or at risk of making mistakes.
120-
It is therefore recommended to use application-generated IDs instead.
121-
====
122-
117+
Neo4j reuses its internal IDs when nodes and relationships are deleted.
118+
Applications relying on internal Neo4j IDs are, as a result, brittle and can be inaccurate.
119+
It is recommended to use application-generated IDs instead.
123120

124121
[[order-nodes-by-expression]]
125122
== Order nodes by expression

modules/ROOT/pages/functions/scalar.adoc

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
Scalar functions return a single value.
88

9-
109
[IMPORTANT]
1110
====
1211
The `length()` and `size()` functions are quite similar, and so it is important to take note of the difference.
@@ -191,8 +190,8 @@ However, no guarantees are given regarding the order of the returned ID values o
191190
Outside of the scope of a single transaction, no guarantees are given about the mapping between ID values and elements.
192191

193192
. Neo4j reuses its internal IDs when nodes and relationships are deleted.
194-
This means that applications using, and relying on internal Neo4j IDs, are brittle or at risk of making mistakes.
195-
It is therefore recommended to rather use application-generated IDs.
193+
Applications relying on internal Neo4j IDs are, as a result, brittle and can be inaccurate.
194+
It is therefore recommended to use application-generated IDs.
196195

197196

198197
.Considerations
@@ -361,22 +360,29 @@ It is recommended to use xref:functions/scalar.adoc#functions-elementid[`element
361360

362361
|===
363362

364-
The function `id()` returns a node or a relationship identifier, unique by an object type and a database.
363+
There are important considerations to bear in mind when using `id()`:
364+
365+
. The function `id()` returns a node or a relationship identifier, unique by an object type and a database.
365366
Therefore, `id()` can return the same value for both nodes and relationships in the same database.
366367

367-
Neo4j implements the id so that every node and relationship in a database has an identifier.
368+
. Neo4j implements the ID so that every node and relationship in a database has an identifier.
368369
The identifier for a node or relationship is guaranteed to be unique among other nodes' and relationships' identifiers in the same database, within the scope of a single transaction.
369370

371+
. Neo4j reuses its internal IDs when nodes and relationships are deleted.
372+
Applications relying on internal Neo4j IDs are, as a result, brittle and can be inaccurate.
373+
It is therefore recommended to use application-generated IDs instead.
374+
375+
370376
[NOTE]
371377
====
372378
On a link:{neo4j-docs-base-uri}/operations-manual/{page-version}/database-administration/composite-databases/concepts/[composite database], the `id()` function should be used with caution.
373379
It is recommended to use xref:functions/scalar.adoc#functions-elementid[`elementId()`] instead.
374380
375-
When called in database-specific subqueries, the resulting id value for a node or relationship is local to that database.
376-
The local id for nodes or relationships from different databases may be the same.
381+
When called in database-specific subqueries, the resulting ID value for a node or relationship is local to that database.
382+
The local ID for nodes or relationships from different databases may be the same.
377383
378-
When called from the root context of a query, the resulting value is an extended id for the node or relationship.
379-
The extended id is likely different from the local id for the same node or relationship.
384+
When called from the root context of a query, the resulting value is an extended ID for the node or relationship.
385+
The extended ID is likely different from the local ID for the same node or relationship.
380386
====
381387

382388

0 commit comments

Comments
 (0)