@@ -7,7 +7,7 @@ use crate::{
77} ;
88
99use super :: {
10- frequency, pick,
10+ frequency, pick, pick_index ,
1111 plan:: { Assertion , Interaction , InteractionStats , ResultSet } ,
1212 ArbitraryFrom ,
1313} ;
@@ -34,6 +34,8 @@ pub(crate) enum Property {
3434 InsertSelect {
3535 /// The insert query
3636 insert : Insert ,
37+ /// Selected row index
38+ row_index : usize ,
3739 /// Additional interactions in the middle of the property
3840 queries : Vec < Query > ,
3941 /// The select query
@@ -73,6 +75,7 @@ impl Property {
7375 match self {
7476 Property :: InsertSelect {
7577 insert,
78+ row_index,
7679 queries,
7780 select,
7881 } => {
@@ -83,7 +86,7 @@ impl Property {
8386 ) ;
8487
8588 // Pick a random row within the insert values
86- let row = pick ( & insert. values , & mut rand :: thread_rng ( ) ) . clone ( ) ;
89+ let row = insert. values [ * row_index ] . clone ( ) ;
8790
8891 // Assume that the table exists
8992 let assumption = Interaction :: Assumption ( Assertion {
@@ -202,7 +205,8 @@ fn property_insert_select<R: rand::Rng>(
202205 . collect :: < Vec < _ > > ( ) ;
203206
204207 // Pick a random row to select
205- let row = pick ( & rows, rng) . clone ( ) ;
208+ let row_index = pick_index ( rows. len ( ) , rng) . clone ( ) ;
209+ let row = rows[ row_index] . clone ( ) ;
206210
207211 // Insert the rows
208212 let insert_query = Insert {
@@ -248,6 +252,7 @@ fn property_insert_select<R: rand::Rng>(
248252
249253 Property :: InsertSelect {
250254 insert : insert_query,
255+ row_index,
251256 queries,
252257 select : select_query,
253258 }
0 commit comments