mirror of
https://github.com/quickwit-oss/tantivy.git
synced 2026-01-06 09:12:55 +00:00
[tantivy] Fix for schema deserialization error (#902)
Co-authored-by: Pasha <pasha@izihawa.net>
This commit is contained in:
@@ -58,6 +58,7 @@ rand = "0.7"
|
||||
maplit = "1"
|
||||
matches = "0.1.8"
|
||||
proptest = "0.10"
|
||||
serde_yaml = "0.8.13"
|
||||
|
||||
[dev-dependencies.fail]
|
||||
version = "0.4"
|
||||
|
||||
@@ -223,8 +223,8 @@ impl<'de> Deserialize<'de> for FieldEntry {
|
||||
if ty.is_some() {
|
||||
return Err(de::Error::duplicate_field("type"));
|
||||
}
|
||||
let type_string = map.next_value()?;
|
||||
match type_string {
|
||||
let type_string = map.next_value::<String>()?;
|
||||
match type_string.as_str() {
|
||||
"hierarchical_facet" => {
|
||||
field_type = Some(FieldType::HierarchicalFacet);
|
||||
}
|
||||
@@ -241,7 +241,7 @@ impl<'de> Deserialize<'de> for FieldEntry {
|
||||
specified before `options`";
|
||||
return Err(de::Error::custom(msg));
|
||||
}
|
||||
Some(ty) => match ty {
|
||||
Some(ref ty) => match ty.as_str() {
|
||||
"text" => field_type = Some(FieldType::Str(map.next_value()?)),
|
||||
"u64" => field_type = Some(FieldType::U64(map.next_value()?)),
|
||||
"i64" => field_type = Some(FieldType::I64(map.next_value()?)),
|
||||
@@ -309,4 +309,17 @@ mod tests {
|
||||
_ => panic!("expected FieldType::Str"),
|
||||
}
|
||||
}
|
||||
#[test]
|
||||
fn test_yaml_deserialization() {
|
||||
let schema_content = r#"
|
||||
name: text
|
||||
type: text
|
||||
options:
|
||||
indexing:
|
||||
record: position
|
||||
tokenizer: default
|
||||
stored: true
|
||||
"#;
|
||||
serde_yaml::from_str::<FieldEntry>(schema_content).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user