-
Is there a way to perform the following query ? SELECT *
FROM table_name
WHERE (key_part_1, key_part_2) IN ( ('B',1), ('C',2) ); Like for example: let condition = Condition::all().add((Column::key_part_1, Column::key_part_2).in(vec![('B',1), ('C',2)]));
let data = Entity::find().filter(condition).all(db).await |
Beta Was this translation helpful? Give feedback.
Answered by
billy1624
Jun 1, 2022
Replies: 2 comments 2 replies
-
Hey @karatakis, it's not support at the moment. But I think we could support it as all three db backends support such "tuple" conditioning. Would you like to create a PR for it on SeaQuery? |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
billy1624
-
I guess I found a way: Expr::tuple([
Column::One.into_simple_expr(),
Column::Two.into_simple_expr(),
])
.in_tuples([
["one_value_1", "two_value_1"],
["one_value_2", "two_value_2"],
]); For "not in" is a bit harder, cause we don't have SimpleExpr::Binary(
Box::new(SimpleExpr::Tuple(vec![
Column::One.into_simple_expr(),
Column::Two.into_simple_expr(),
])),
BinOper::NotIn,
Box::new(SimpleExpr::Tuple(vec![
SimpleExpr::Values(vec![
"one_value_1".into(),
"two_value_1".into(),
]),
SimpleExpr::Values(vec![
"one_value_2".into(),
"two_value_2".into(),
]),
])),
); |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey @karatakis, it's not support at the moment. But I think we could support it as all three db backends support such "tuple" conditioning. Would you like to create a PR for it on SeaQuery?