Skip to content

Commit ed288e1

Browse files
authored
DOC-12319: Sequence examples need to change (#269)
Add updated INSERT example for 7.6.4
1 parent 84950f3 commit ed288e1

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
@@ -188,7 +188,7 @@ INSERT INTO bookings
188188
====
189189

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

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

0 commit comments

Comments
 (0)