This works when fetching a document from the database, but it fails when trying to persist a new document to the database.
The problem is in Doctrine\ODM\CouchDB\UnitOfWork::flush() where the field values are converted to JSON values. The _rev version field is included in the JSON, even if it is null. This results in a 400 bad request response from CouchDB.
Our workaround is to replace line 1072 with the following code snippet:
Rather than testing the JSON name, it might be more consistent with the rest of your design to test $class->fieldMappings[$fieldName]['isVersionField'] or to check whether $fieldName is equal to $class->versionField.
We tried mapping the CouchDB _rev string to a PHP property. The line we used in the XML mapping file was:
This works when fetching a document from the database, but it fails when trying to persist a new document to the database.
The problem is in
Doctrine\ODM\CouchDB\UnitOfWork::flush()
where the field values are converted to JSON values. The _rev version field is included in the JSON, even if it is null. This results in a 400 bad request response from CouchDB.Our workaround is to replace line 1072 with the following code snippet:
Rather than testing the JSON name, it might be more consistent with the rest of your design to test
$class->fieldMappings[$fieldName]['isVersionField']
or to check whether$fieldName
is equal to$class->versionField
.