Remove generics on find_by_id

This commit is contained in:
Billy Chan 2021-09-06 18:48:00 +08:00 committed by Chris Tsang
parent dd7585c4e6
commit 26cd0846d2

View File

@ -239,23 +239,15 @@ pub trait EntityTrait: EntityName {
/// vec![2i32.into(), 3i32.into()]
/// )]);
/// ```
fn find_by_id<V>(values: V) -> Select<Self>
where
V: IntoValueTuple,
{
fn find_by_id(values: <Self::PrimaryKey as PrimaryKeyTrait>::ValueType) -> Select<Self> {
let mut select = Self::find();
let mut keys = Self::PrimaryKey::iter();
for v in values.into_value_tuple() {
if let Some(key) = keys.next() {
let col = key.into_column();
select = select.filter(col.eq(v));
} else {
panic!("primary key arity mismatch");
}
}
if keys.next().is_some() {
panic!("primary key arity mismatch");
}
select
}