MCPcopy Create free account
hub / github.com/SeaQL/sea-orm / prepare_condition

Function prepare_condition

src/query/loader.rs:406–441  ·  view source on GitHub ↗
(table: &TableRef, col: &Identity, keys: &[ValueTuple])

Source from the content-addressed store, hash-verified

404}
405
406fn 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
443fn table_column(tbl: &TableRef, col: &DynIden) -> ColumnRef {
444 match tbl.to_owned() {

Callers 3

load_oneMethod · 0.85
load_manyMethod · 0.85
load_many_to_manyMethod · 0.85

Calls 5

table_columnFunction · 0.85
into_iterMethod · 0.80
addMethod · 0.80
newFunction · 0.50
ColumnEnum · 0.50

Tested by

no test coverage detected