Skip to main content

sql_orm_query/
insert.rs

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