I'm working with ArangoDB and facing an issue with an AQL upsert operation where the CreateDate field is expected to be set only during insert operations and remain unchanged during updates. However, after performing an upsert, I noticed that the CreateDate field becomes empty for updates, which is not the intended behavior. The issue does not occur during inserts, where CreateDate is correctly set. Here's the relevant part of my code:
UPSERT { _key: entity._key }
INSERT MERGE(entity, { CreateDate: DATE_ISO8601(DATE_NOW()), UpdatedDate: DATE_ISO8601(DATE_NOW()) })
UPDATE MERGE(entity, { UpdatedDate: DATE_ISO8601(DATE_NOW()) })
IN @@collectionName
The CreateDate should only be set when a new document is inserted and should not be modified if the document exists and is being updated. However, during an update operation, CreateDate ends up being empty.
My question:
Why does the CreateDate field become empty during an update operation, even though my intention is to only modify it during insert operations?
I've confirmed that the issue does not occur during insert operations CreateDate is correctly set.