toasty_core/stmt/insert_table.rs
1use super::InsertTarget;
2use crate::schema::db::{ColumnId, TableId};
3
4/// A lowered insert target specifying a database table and its columns.
5///
6/// Used as the `Table` variant of [`InsertTarget`] after the query engine
7/// lowers model-level inserts to table-level operations.
8///
9/// # Examples
10///
11/// ```ignore
12/// use toasty_core::stmt::InsertTable;
13/// use toasty_core::schema::db::{TableId, ColumnId};
14///
15/// let target = InsertTable {
16/// table: TableId(0),
17/// columns: vec![ColumnId { table: TableId(0), index: 0 }],
18/// };
19/// ```
20#[derive(Debug, Clone, PartialEq)]
21pub struct InsertTable {
22 /// The database table to insert into.
23 pub table: TableId,
24
25 /// The columns to populate, in order matching the value rows.
26 pub columns: Vec<ColumnId>,
27}
28
29impl From<InsertTable> for InsertTarget {
30 fn from(value: InsertTable) -> Self {
31 Self::Table(value)
32 }
33}
34
35impl From<&InsertTable> for TableId {
36 fn from(value: &InsertTable) -> Self {
37 value.table
38 }
39}