Comments (2)
This is the expected behavior. With OPTIONS {"mergeObjects": false}
, the attributes you specify will be set to the specified values. Attributes you don't specify remain, regardless of mergeObjects
. If you want to remove attributes selectively, set them to null
in an UPDATE
operation with OPTIONS { keepNull: false }
:
UPDATE { _key: "C", test2: null } IN Client OPTIONS { keepNull: false }
Or you can consider specifying all attributes of the document you want to keep and use a REPLACE
operation, but be careful not to remove more attributes than desired - only the ones stated in the query plus immutable system attributes will remain.
from arangodb.
Hi @konsultaner, the implemented behavior of mergeObjects
is
- for any attributes that are present in the overwrite value but not in the source document:
- add all attributes to the document which are present in the overwrite value but not in the source document. A special case is when
keepNull=false
is removed, in which case the attributes which arenull
in the overwrite attribute value will be removed from the target document.
- add all attributes to the document which are present in the overwrite value but not in the source document. A special case is when
- for any attributes that are present in the overwrite value and also in the source document:
- if
mergeObjects=false
, overwrite the value of the attribute in the source document with the overwrite attribute value. - if
mergeObjects=true
, overwrite the value of the attribute in the source document with the overwrite attribute value if the attribute value in the source document is not an object (i.e. merging not possible, so we are overwriting). - if
mergeObjects=true
, merge the value of attribute in the source document with the overwrite attribute value if they are both objects (merging possible).
- if
The algorithm is not performed on the very top level (i.e. the source document and the overwrite value). Instead it is performed for every top-level attribute present in the overwrite value individually. When merging two attribute values objects, the merging is also performed recursively using the same algorithm.
I understand that this behavior may not always be the desired behavior, but the merging algorithm shouldn't be changed in an incompatible way to avoid incompatibility. In case a different merging algorithm is needed, there are multiple options:
- implement the custom merging in the client application (requires fetching the original document first, so may not work for large amounts and is subject to data races if there are other concurrent update operations).
- implement the custom merging as a new option in the database. This would mean another hard-coded merging algorithm, which may or may not be general enough to suit everyone's needs. Also requires support from all relevant drivers in order to be able to use it properly.
- implement the custom merging in the AQL query, using built-in AQL functions (example following)
FOR doc IN collection
REPLACE doc WITH MERGE_RECURSIVE(@update) IN collection
Note that this query is not providing a different merge algorithm, but it may be adjusted to your needs. I currently can't tell what merge algorithm you have in mind.
from arangodb.
Related Issues (20)
- RocksDB encountered a background error during a compaction operation: HOT 2
- GraphAR export / import
- optimizer should consider projections and stored values when selecting indexes HOT 5
- Render large graph - rendering bug - select graph traversal order
- Fedora 40 fatal error when login HOT 4
- Update leader election failed. error="context deadline exceeded": Deployment Using the ArangoDB Starter in Docker
- Primary Sort ArangoSearch is not flexible, What's other way do with sort in ArangoSearch HOT 18
- Documentation conflict. Is Active Failover mode deprecated? HOT 2
- ArangoSearch view: sort after pagination breaks view performance HOT 3
- InvalidImageName HOT 2
- How to join arangodb community slack channel? HOT 1
- Search-Alias View can't search on field type array HOT 3
- Arangorestore error 'Connection closed by remote'
- Understanding how switching a license works
- Number Overflow when using AVG HOT 1
- Can't add inverted indexes contains same sort fields of other collections to a view search-alias HOT 1
- Can't add a index collection contains primary sort different config primary sort of previous indexes to a search-alias view HOT 8
- High Security vulnerability in Runc HOT 1
- Error doing filtered upsert query, comparing the keys of 2 vertexes HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from arangodb.