@@ -284,9 +284,10 @@ fn array_index() {
284284 // Index with one level of unnest
285285 let index_configuration = ArrayIndexConfiguration :: new ( QueryLanguage :: N1QL , "likes" , "" ) ;
286286
287- assert ! ( default_collection
288- . create_array_index( "one_level" , & index_configuration, )
289- . unwrap( ) ) ;
287+ let result = default_collection
288+ . create_array_index ( "one_level" , & index_configuration)
289+ . unwrap ( ) ;
290+ assert ! ( result) ;
290291
291292 let query = Query :: new (
292293 db,
@@ -305,18 +306,12 @@ fn array_index() {
305306 assert ! ( result. next( ) . is_none( ) ) ;
306307
307308 // Index with two levels of unnest
308- /*let index_configuration = ArrayIndexConfiguration::new(
309- QueryLanguage::N1QL,
310- "contacts[].phones",
311- "",//"type",
312- );
309+ let index_configuration =
310+ ArrayIndexConfiguration :: new ( QueryLanguage :: N1QL , "contacts[].phones" , "type" ) ;
313311
314312 assert ! ( default_collection
315- .create_array_index(
316- "myindex",
317- &index_configuration,
318- ).unwrap()
319- );
313+ . create_array_index( "two_levels" , & index_configuration, )
314+ . unwrap( ) ) ;
320315
321316 let query = Query :: new (
322317 db,
@@ -325,18 +320,29 @@ fn array_index() {
325320 FROM _
326321 UNNEST _.contacts as contact
327322 UNNEST contact.phones as phone
328- WHERE phone.type = 'mobile'"#
329- ).unwrap();
323+ WHERE phone.type = 'mobile'"# ,
324+ )
325+ . unwrap ( ) ;
330326
331327 println ! ( "Explain: {}" , query. explain( ) . unwrap( ) ) ;
332328
333329 let index = get_index_name_from_explain ( & query. explain ( ) . unwrap ( ) ) . unwrap ( ) ;
334330 assert_eq ! ( index, "two_levels" ) ;
335331
336332 let mut result = query. execute ( ) . unwrap ( ) ;
333+
337334 let row = result. next ( ) . unwrap ( ) ;
338- assert_eq!(row.as_array().to_json(), r#"["Sam","travel"]"#);
335+ assert_eq ! (
336+ row. as_array( ) . to_json( ) ,
337+ r#"["Sam","primary","310-123-6789"]"#
338+ ) ;
339339
340- assert!(result.next().is_none());*/
340+ let row = result. next ( ) . unwrap ( ) ;
341+ assert_eq ! (
342+ row. as_array( ) . to_json( ) ,
343+ r#"["Sam","secondary","206-123-6789"]"#
344+ ) ;
345+
346+ assert ! ( result. next( ) . is_none( ) ) ;
341347 } )
342348}
0 commit comments