private void TransformScriptOrDisableVersioningIfNeeded(DocumentsOperationContext context, PatchDocument patch, BlittableJsonReaderObject reader, Document document, PatchRequest patchRequest) { if (patch == null && Options.DisableVersioningBundle == false) { return; } BlittableJsonReaderObject newMetadata; reader.TryGet(Constants.Metadata.Key, out newMetadata); if (patch != null) { LazyStringValue key; if (newMetadata != null) { if (newMetadata.TryGet(Constants.Metadata.Id, out key)) { document.Key = key; } } var patchResult = patch.Apply(context, document, patchRequest); if (patchResult != null && patchResult.ModifiedDocument.Equals(document.Data) == false) { document.Data = patchResult.ModifiedDocument; } } if (Options.DisableVersioningBundle == false || newMetadata == null) { return; } newMetadata.Modifications = new DynamicJsonValue(newMetadata) { [Constants.Versioning.RavenDisableVersioning] = false }; }