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:
from datetime import timedelta |
|
import couchbase.subdocument as SD |
from couchbase.auth import PasswordAuthenticator |
from couchbase.cluster import Cluster |
from couchbase.diagnostics import ServiceType |
from couchbase.exceptions import InvalidArgumentException |
from couchbase.options import (ClusterOptions, |
WaitUntilReadyOptions)
|
|
auth = PasswordAuthenticator('Administrator', 'password') |
opts = ClusterOptions(auth) |
cluster = Cluster.connect('couchbase://192.168.107.128', opts) |
|
cluster.wait_until_ready(timedelta(seconds=3), |
WaitUntilReadyOptions(service_types=[ServiceType.KeyValue, ServiceType.Query])) |
|
collection = (cluster |
.bucket('default') |
.default_collection())
|
|
key = 'test_doc' |
collection.upsert(key, { 'content': 'test content'}) |
|
xattr_array = 'xattr_array' |
specs = [ |
SD.upsert(xattr_array, [], xattr=True), |
SD.array_addunique(xattr_array, SD.MutationMacro.cas()),
|
]
|
try: |
collection.mutate_in(key, specs)
|
except InvalidArgumentException as ex: |
print(ex) |
|
collection.mutate_in(key, (SD.upsert(xattr_array, [], xattr=True),)) |
specs = [ |
SD.array_addunique(xattr_array, SD.MutationMacro.cas()),
|
]
|
try: |
collection.mutate_in(key, specs)
|
except InvalidArgumentException as ex: |
print(ex) |
Output:
InvalidArgumentException(<ec=3, category=couchbase.common, message=invalid_argument (3), context=SubdocumentErrorContext({'last_dispatched_to': '192.168.107.130:11210', 'last_dispatched_from': '192.168.107.1:60895', 'retry_attempts': 0, 'key': 'test_doc', 'bucket_name': 'default', 'scope_name': '_default', 'collection_name': '_default', 'opaque': 9, 'status_code': 4, 'error_map_info': {'code': 4, 'name': 'EINVAL', 'description': 'Invalid packet', 'attributes': {9, 2}}, 'extended_error_info': {'reference': '', 'context': 'Request flags invalid'}, 'context_type': 'SubdocumentErrorContext'}), C Source=/Users/jaredcasey/GIT/couchbase/clients/python/couchbase-python-client/src/subdoc_ops.cxx:516>)
|
InvalidArgumentException(<ec=3, category=couchbase.common, message=invalid_argument (3), context=SubdocumentErrorContext({'last_dispatched_to': '192.168.107.130:11210', 'last_dispatched_from': '192.168.107.1:60895', 'retry_attempts': 0, 'key': 'test_doc', 'bucket_name': 'default', 'scope_name': '_default', 'collection_name': '_default', 'opaque': 11, 'status_code': 4, 'error_map_info': {'code': 4, 'name': 'EINVAL', 'description': 'Invalid packet', 'attributes': {9, 2}}, 'extended_error_info': {'reference': '', 'context': 'Request flags invalid'}, 'context_type': 'SubdocumentErrorContext'}), C Source=/Users/jaredcasey/GIT/couchbase/clients/python/couchbase-python-client/src/subdoc_ops.cxx:516>)
|
TODO: create and link an MB