@@ -509,6 +509,37 @@ add('test_select_all_with_batch_size', function(g)
509509 t .assert_equals (objects , get_by_ids (customers , {1 , 2 , 3 , 4 , 5 , 6 }))
510510end )
511511
512+ add (' test_select_by_primary_index' , function (g )
513+ local customers = insert_customers (g , {
514+ {
515+ id = 1 , name = " Elizabeth" , last_name = " Jackson" ,
516+ age = 12 , city = " New York" ,
517+ }, {
518+ id = 2 , name = " Mary" , last_name = " Brown" ,
519+ age = 46 , city = " Los Angeles" ,
520+ }, {
521+ id = 3 , name = " David" , last_name = " Smith" ,
522+ age = 33 , city = " Los Angeles" ,
523+ },
524+ })
525+
526+ table.sort (customers , function (obj1 , obj2 ) return obj1 .id < obj2 .id end )
527+
528+ local conditions = {{' ==' , ' id_index' , 3 }}
529+ local result , err = g .cluster .main_server .net_box :eval ([[
530+ local crud = require('crud')
531+
532+ local conditions = ...
533+
534+ local result, err = crud.select('customers', conditions)
535+ return result, err
536+ ]] , {conditions })
537+
538+ t .assert_equals (err , nil )
539+ local objects = crud .unflatten_rows (result .rows , result .metadata )
540+ t .assert_equals (objects , get_by_ids (customers , {3 }))
541+ end )
542+
512543add (' test_eq_condition_with_index' , function (g )
513544 local customers = insert_customers (g , {
514545 {
@@ -538,7 +569,7 @@ add('test_eq_condition_with_index', function(g)
538569 table.sort (customers , function (obj1 , obj2 ) return obj1 .id < obj2 .id end )
539570
540571 local conditions = {
541- {' ==' , ' age ' , 33 },
572+ {' ==' , ' age_index ' , 33 },
542573 }
543574
544575 -- no after
@@ -593,7 +624,7 @@ add('test_ge_condition_with_index', function(g)
593624 table.sort (customers , function (obj1 , obj2 ) return obj1 .id < obj2 .id end )
594625
595626 local conditions = {
596- {' >=' , ' age ' , 33 },
627+ {' >=' , ' age_index ' , 33 },
597628 }
598629
599630 -- no after
@@ -648,7 +679,7 @@ add('test_le_condition_with_index',function(g)
648679 table.sort (customers , function (obj1 , obj2 ) return obj1 .id < obj2 .id end )
649680
650681 local conditions = {
651- {' <=' , ' age ' , 33 },
682+ {' <=' , ' age_index ' , 33 },
652683 }
653684
654685 -- no after
@@ -703,7 +734,7 @@ add('test_lt_condition_with_index', function(g)
703734 table.sort (customers , function (obj1 , obj2 ) return obj1 .id < obj2 .id end )
704735
705736 local conditions = {
706- {' <' , ' age ' , 33 },
737+ {' <' , ' age_index ' , 33 },
707738 }
708739
709740 -- no after
0 commit comments