Merge pull request #572 from ppamorim/ignore-null-nested-obj

Add support of nested null
This commit is contained in:
Clément Renault 2020-03-31 16:33:16 +02:00 committed by GitHub
commit 065da3d613
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 37 additions and 1 deletions

View File

@ -3,3 +3,4 @@
- Add the number of hits in search result (#541)
- Add support for aligned crop in search result (#543)
- Sanitize the content displayed in the web interface (#539)
- Add support of nested null and boolean values (#571 and #568)

View File

@ -88,7 +88,7 @@ impl ser::Serializer for ConvertToString {
}
fn serialize_unit(self) -> Result<Self::Ok, Self::Error> {
Err(SerializerError::UnserializableType { type_name: "()" })
Ok(String::new())
}
fn serialize_unit_struct(self, _name: &'static str) -> Result<Self::Ok, Self::Error> {

View File

@ -76,3 +76,38 @@ fn check_add_documents_with_nested_boolean() {
assert_eq!(status_code, 200);
assert_eq!(response["status"], "processed");
}
// Test issue https://github.com/meilisearch/MeiliSearch/issues/571
#[test]
fn check_add_documents_with_nested_null() {
let mut server = common::Server::with_uid("tasks");
// 1 - Create the index with no primary_key
let body = json!({ "uid": "tasks" });
let (response, status_code) = server.create_index(body);
assert_eq!(status_code, 201);
assert_eq!(response["primaryKey"], json!(null));
// 2 - Add a document that contains a null in a nested object
let body = json!([{
"id": 0,
"foo": {
"bar": null
}
}]);
let url = "/indexes/tasks/documents";
let (response, status_code) = server.post_request(&url, body);
eprintln!("{:#?}", response);
assert_eq!(status_code, 202);
let update_id = response["updateId"].as_u64().unwrap();
server.wait_update_id(update_id);
// 3 - Check update sucess
let (response, status_code) = server.get_update_status(update_id);
assert_eq!(status_code, 200);
assert_eq!(response["status"], "processed");
}