You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: modules/n1ql/pages/n1ql-language-reference/sequenceops.adoc
+31-4Lines changed: 31 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -188,7 +188,7 @@ INSERT INTO bookings
188
188
====
189
189
190
190
[[ex-nextval-key]]
191
-
.Insert a sequential value in a document key
191
+
.Insert a sequential value in a document key and body
192
192
====
193
193
The following statement uses the `ordNum` sequence to generate the document key and a booking number within the body of the document.
194
194
@@ -201,6 +201,12 @@ INSERT INTO bookings
201
201
RETURNING META().id, *;
202
202
----
203
203
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
+
204
210
.Results
205
211
[source,json]
206
212
----
@@ -215,12 +221,33 @@ INSERT INTO bookings
215
221
]
216
222
----
217
223
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.
220
247
====
221
248
222
249
[[ex-nextval-same]]
223
-
.Insert the same sequential value in a document key and body
250
+
.Insert a sequential value with INSERT SELECT
224
251
====
225
252
The following statement uses an INSERT SELECT statement.
226
253
With this query, the document key and document value are both generated within the same document.
0 commit comments