Apply review comments

This commit is contained in:
Clément Renault 2024-07-11 11:00:27 +02:00
parent 837274f853
commit 6e80364c50
No known key found for this signature in database
GPG key ID: F250A4C4E3AE5F5F
5 changed files with 14 additions and 8 deletions

View file

@ -216,11 +216,11 @@ where
let mut documents_batch_builder = tempfile::tempfile().map(DocumentsBatchBuilder::new)?;
let mut documents_to_remove = RoaringBitmap::new();
let context: Dynamic = match context {
let context: Option<Dynamic> = match context {
Some(context) => {
serde_json::from_value(context.into()).map_err(InternalError::SerdeJson)?
Some(serde_json::from_value(context.into()).map_err(InternalError::SerdeJson)?)
}
None => Dynamic::from(()),
None => None,
};
enum DocumentEdition {
@ -244,7 +244,9 @@ where
let document_id = &json_document[primary_key];
let mut scope = Scope::new();
scope.push_constant_dynamic("context", context.clone());
if let Some(context) = context.as_ref().cloned() {
scope.push_constant_dynamic("context", context.clone());
}
scope.push("doc", rhai_document);
// That's were the magic happens. We run the user script
// which edits "doc" scope variable reprensenting the document

View file

@ -60,7 +60,7 @@ impl<'t> ImmutableObkvs<'t> {
let name = self.fields_ids_map.name(id).ok_or(
crate::error::FieldIdMapMissingEntry::FieldId {
field_id: id,
process: "allobkv_to_rhaimap",
process: "all_obkv_to_rhaimap",
},
)?;
let value = serde_json::from_slice(value)