Details
-
Task
-
Resolution: Unresolved
-
Major
-
None
-
None
-
None
-
0
Description
It would appear that the server does not allow the use of a MutateInMacro when doing an arrayaddunique operation. Have tested on 7.2.5-7538 and 7.6.0-2010.
Simple program:
const couchbase = require('./dist/couchbase') |
|
async function main() { |
try { |
const clusterConnStr = 'couchbase://192.168.107.128' |
const username = 'Administrator' |
const password = 'password' |
const cluster = await couchbase.connect(clusterConnStr, {
|
username: username,
|
password: password,
|
timeouts: {
|
kvTimeout: 10000, // milliseconds |
},
|
})
|
const bucket = cluster.bucket('default') |
const collection = bucket.defaultCollection()
|
const testKey = 'test-doc' |
const xattrPath = 'xattr-path' |
await collection.upsert(testKey, { content: 'doc content' }) |
|
try { |
await collection.mutateIn(testKey, [
|
couchbase.MutateInSpec.upsert(xattrPath, [], { xattr: true }), |
couchbase.MutateInSpec.arrayAddUnique(xattrPath, couchbase.MutateInMacro.Cas),
|
])
|
} catch (err) { |
console.error(err)
|
}
|
|
await collection.mutateIn(testKey, [
|
couchbase.MutateInSpec.upsert(xattrPath, [], { xattr: true }), |
])
|
|
try { |
await collection.mutateIn(testKey, [
|
couchbase.MutateInSpec.upsert(xattrPath, [], { xattr: true }), |
couchbase.MutateInSpec.arrayAddUnique(xattrPath, couchbase.MutateInMacro.Cas),
|
])
|
} catch (err) { |
console.error(err)
|
}
|
} catch (e) { |
throw e |
}
|
}
|
|
main()
|
.then(() => {
|
console.log('Finished. Exiting app...') |
})
|
.catch((err) => { |
console.log('ERR: ', err) |
console.log('Exiting app...') |
process.exit(1)
|
})
|
|
Output:
[InvalidArgumentError: invalid argument] {
|
cause: [Error: invalid_argument (3)] {
|
ctxtype: 'subdocument',
|
code: 3,
|
id: 'test-doc',
|
opaque: 9,
|
cas: Cas<0>,
|
status_code: 4,
|
enhanced_error_info: { reference: '', context: 'Request flags invalid' },
|
last_dispatched_to: '192.168.107.129:11210',
|
last_dispatched_from: '192.168.107.1:60725',
|
retry_attempts: 0,
|
retry_reasons: [],
|
first_error_path: undefined,
|
first_error_index: undefined,
|
deleted: false
|
},
|
context: undefined
|
}
|
[InvalidArgumentError: invalid argument] {
|
cause: [Error: invalid_argument (3)] {
|
ctxtype: 'subdocument',
|
code: 3,
|
id: 'test-doc',
|
opaque: 11,
|
cas: Cas<0>,
|
status_code: 4,
|
enhanced_error_info: { reference: '', context: 'Request flags invalid' },
|
last_dispatched_to: '192.168.107.129:11210',
|
last_dispatched_from: '192.168.107.1:60725',
|
retry_attempts: 0,
|
retry_reasons: [],
|
first_error_path: undefined,
|
first_error_index: undefined,
|
deleted: false
|
},
|
context: undefined
|
}
|
TODO: create and link an MB