mirror of
				https://github.com/meilisearch/meilisearch.git
				synced 2025-10-30 23:46:28 +00:00 
			
		
		
		
	fix(http): Fix the query parameter in the Documents route
This commit is contained in:
		| @@ -1,5 +1,4 @@ | ||||
| use crate::common::Server; | ||||
| use crate::common::{GetAllDocumentsOptions, GetDocumentOptions}; | ||||
| use crate::common::{GetAllDocumentsOptions, GetDocumentOptions, Server}; | ||||
|  | ||||
| use serde_json::json; | ||||
|  | ||||
| @@ -71,7 +70,6 @@ async fn get_document() { | ||||
|         }) | ||||
|     ); | ||||
|  | ||||
|     /* This currently doesn't work but should be fixed by #2433 | ||||
|     let (response, code) = index | ||||
|         .get_document( | ||||
|             0, | ||||
| @@ -87,7 +85,6 @@ async fn get_document() { | ||||
|             "nested": { "content": "foobar" }, | ||||
|         }) | ||||
|     ); | ||||
|     */ | ||||
| } | ||||
|  | ||||
| #[actix_rt::test] | ||||
| @@ -289,6 +286,91 @@ async fn test_get_all_documents_attributes_to_retrieve() { | ||||
|     } | ||||
| } | ||||
|  | ||||
| #[actix_rt::test] | ||||
| async fn get_document_s_nested_attributes_to_retrieve() { | ||||
|     let server = Server::new().await; | ||||
|     let index = server.index("test"); | ||||
|     index.create(None).await; | ||||
|     let documents = json!([ | ||||
|         { | ||||
|             "id": 0, | ||||
|             "content.truc": "foobar", | ||||
|         }, | ||||
|         { | ||||
|             "id": 1, | ||||
|             "content": { | ||||
|                 "truc": "foobar", | ||||
|                 "machin": "bidule", | ||||
|             }, | ||||
|         }, | ||||
|     ]); | ||||
|     let (_, code) = index.add_documents(documents, None).await; | ||||
|     assert_eq!(code, 202); | ||||
|     index.wait_task(0).await; | ||||
|  | ||||
|     let (response, code) = index | ||||
|         .get_document( | ||||
|             0, | ||||
|             Some(GetDocumentOptions { | ||||
|                 fields: Some(vec!["content"]), | ||||
|             }), | ||||
|         ) | ||||
|         .await; | ||||
|     assert_eq!(code, 200); | ||||
|     assert_eq!(response, json!({})); | ||||
|     let (response, code) = index | ||||
|         .get_document( | ||||
|             1, | ||||
|             Some(GetDocumentOptions { | ||||
|                 fields: Some(vec!["content"]), | ||||
|             }), | ||||
|         ) | ||||
|         .await; | ||||
|     assert_eq!(code, 200); | ||||
|     assert_eq!( | ||||
|         response, | ||||
|         json!({ | ||||
|             "content": { | ||||
|                 "truc": "foobar", | ||||
|                 "machin": "bidule", | ||||
|             }, | ||||
|         }) | ||||
|     ); | ||||
|  | ||||
|     let (response, code) = index | ||||
|         .get_document( | ||||
|             0, | ||||
|             Some(GetDocumentOptions { | ||||
|                 fields: Some(vec!["content.truc"]), | ||||
|             }), | ||||
|         ) | ||||
|         .await; | ||||
|     assert_eq!(code, 200); | ||||
|     assert_eq!( | ||||
|         response, | ||||
|         json!({ | ||||
|             "content.truc": "foobar", | ||||
|         }) | ||||
|     ); | ||||
|     let (response, code) = index | ||||
|         .get_document( | ||||
|             1, | ||||
|             Some(GetDocumentOptions { | ||||
|                 fields: Some(vec!["content.truc"]), | ||||
|             }), | ||||
|         ) | ||||
|         .await; | ||||
|     assert_eq!(code, 200); | ||||
|     assert_eq!( | ||||
|         response, | ||||
|         json!({ | ||||
|             "content": { | ||||
|                 "truc": "foobar", | ||||
|             }, | ||||
|         }) | ||||
|     ); | ||||
| } | ||||
|  | ||||
| #[actix_rt::test] | ||||
| async fn get_documents_displayed_attributes_is_ignored() { | ||||
|     let server = Server::new().await; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user