fix deserializer

This commit is contained in:
mpostma 2020-10-13 13:08:17 +02:00
parent 086020e543
commit ac7226bb27
3 changed files with 4 additions and 1 deletions

View File

@ -55,6 +55,7 @@ pub struct Deserializer<'a> {
pub documents_fields: DocumentsFields, pub documents_fields: DocumentsFields,
pub schema: &'a Schema, pub schema: &'a Schema,
pub fields: Option<&'a HashSet<FieldId>>, pub fields: Option<&'a HashSet<FieldId>>,
pub displayed: bool,
} }
impl<'de, 'a, 'b> de::Deserializer<'de> for &'b mut Deserializer<'a> { impl<'de, 'a, 'b> de::Deserializer<'de> for &'b mut Deserializer<'a> {
@ -93,7 +94,7 @@ impl<'de, 'a, 'b> de::Deserializer<'de> for &'b mut Deserializer<'a> {
}; };
let is_displayed = self.schema.is_displayed(attr); let is_displayed = self.schema.is_displayed(attr);
if is_displayed && self.fields.map_or(true, |f| f.contains(&attr)) { if !self.displayed || (is_displayed && self.fields.map_or(true, |f| f.contains(&attr))) {
if let Some(attribute_name) = self.schema.name(attr) { if let Some(attribute_name) = self.schema.name(attr) {
let cursor = Cursor::new(value.to_owned()); let cursor = Cursor::new(value.to_owned());
let ioread = SerdeJsonIoRead::new(cursor); let ioread = SerdeJsonIoRead::new(cursor);

View File

@ -243,6 +243,7 @@ impl Index {
documents_fields: self.documents_fields, documents_fields: self.documents_fields,
schema: &schema, schema: &schema,
fields: attributes.as_ref(), fields: attributes.as_ref(),
displayed: true,
}; };
Ok(Option::<T>::deserialize(&mut deserializer)?) Ok(Option::<T>::deserialize(&mut deserializer)?)

View File

@ -197,6 +197,7 @@ pub fn apply_addition<'a, 'b>(
documents_fields: index.documents_fields, documents_fields: index.documents_fields,
schema: &schema, schema: &schema,
fields: None, fields: None,
displayed: false,
}; };
let old_document = Option::<HashMap<String, Value>>::deserialize(&mut deserializer)?; let old_document = Option::<HashMap<String, Value>>::deserialize(&mut deserializer)?;