Skip to content

Commit a7339ec

Browse files
committed
DOC-12319: Sequence examples need to change (#269)
Add updated INSERT example for 7.6.5
1 parent 6c334ef commit a7339ec

File tree

1 file changed

+31
-4
lines changed

1 file changed

+31
-4
lines changed

modules/n1ql/pages/n1ql-language-reference/sequenceops.adoc

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ INSERT INTO bookings
187187
====
188188

189189
[[ex-nextval-key]]
190-
.Insert a sequential value in a document key
190+
.Insert a sequential value in a document key and body
191191
====
192192
The following statement uses the `ordNum` sequence to generate the document key and a booking number within the body of the document.
193193
@@ -200,6 +200,12 @@ INSERT INTO bookings
200200
RETURNING META().id, *;
201201
----
202202
203+
This query gives different results, depending on the version of Couchbase Server.
204+
205+
'''
206+
207+
[.status]##Couchbase Server 7.6–7.6.3##
208+
203209
.Results
204210
[source,json]
205211
----
@@ -214,12 +220,33 @@ INSERT INTO bookings
214220
]
215221
----
216222
217-
Since the key is not part of the document, the query has incremented the sequence twice.
218-
This gives a different sequence number for the document key and the document value, which may not be what you want.
223+
In versions of Couchbase Server prior to 7.6.5, the key is not regarded as part of the document, so this query increments the sequence twice.
224+
This gives a different sequence number for the document key and the document value.
225+
226+
'''
227+
228+
[.status]#Couchbase Server 7.6.5#
229+
230+
.Results
231+
[source,json]
232+
----
233+
[
234+
{
235+
"id": "1001",
236+
"bookings": {
237+
"num": 1001,
238+
"user": 1
239+
}
240+
}
241+
]
242+
----
243+
244+
In Couchbase Server 7.6.5 and later, the entire VALUES clause (key, value, and options) is regarded as a single document, so the query only increments the sequence once.
245+
This gives the same sequence number in the document key and the document value.
219246
====
220247

221248
[[ex-nextval-same]]
222-
.Insert the same sequential value in a document key and body
249+
.Insert a sequential value with INSERT SELECT
223250
====
224251
The following statement uses an INSERT SELECT statement.
225252
With this query, the document key and document value are both generated within the same document.

0 commit comments

Comments
 (0)