(table: &TableRef, col: &Identity, keys: &[ValueTuple])
| 404 | } |
| 405 | |
| 406 | fn prepare_condition(table: &TableRef, col: &Identity, keys: &[ValueTuple]) -> Condition { |
| 407 | let keys = if !keys.is_empty() { |
| 408 | let set: HashSet<_> = keys.iter().cloned().collect(); |
| 409 | set.into_iter().collect() |
| 410 | } else { |
| 411 | Vec::new() |
| 412 | }; |
| 413 | |
| 414 | match col { |
| 415 | Identity::Unary(column_a) => { |
| 416 | let column_a = table_column(table, column_a); |
| 417 | Condition::all().add(Expr::col(column_a).is_in(keys.into_iter().flatten())) |
| 418 | } |
| 419 | Identity::Binary(column_a, column_b) => Condition::all().add( |
| 420 | Expr::tuple([ |
| 421 | SimpleExpr::Column(table_column(table, column_a)), |
| 422 | SimpleExpr::Column(table_column(table, column_b)), |
| 423 | ]) |
| 424 | .in_tuples(keys), |
| 425 | ), |
| 426 | Identity::Ternary(column_a, column_b, column_c) => Condition::all().add( |
| 427 | Expr::tuple([ |
| 428 | SimpleExpr::Column(table_column(table, column_a)), |
| 429 | SimpleExpr::Column(table_column(table, column_b)), |
| 430 | SimpleExpr::Column(table_column(table, column_c)), |
| 431 | ]) |
| 432 | .in_tuples(keys), |
| 433 | ), |
| 434 | Identity::Many(cols) => { |
| 435 | let columns = cols |
| 436 | .iter() |
| 437 | .map(|col| SimpleExpr::Column(table_column(table, col))); |
| 438 | Condition::all().add(Expr::tuple(columns).in_tuples(keys)) |
| 439 | } |
| 440 | } |
| 441 | } |
| 442 | |
| 443 | fn table_column(tbl: &TableRef, col: &DynIden) -> ColumnRef { |
| 444 | match tbl.to_owned() { |
no test coverage detected