Skip to main content

sql_orm_query/
insert.rs

1use crate::expr::TableRef;
2use sql_orm_core::{ColumnValue, Entity, Insertable};
3
4#[derive(Debug, Clone, PartialEq)]
5pub struct InsertQuery {
6    pub into: TableRef,
7    pub values: Vec<ColumnValue>,
8}
9
10impl InsertQuery {
11    pub fn for_entity<E: Entity, I: Insertable<E>>(insertable: &I) -> Self {
12        Self {
13            into: TableRef::for_entity::<E>(),
14            values: insertable.values(),
15        }
16    }
17}