toasty_core/driver/operation/query_sql.rs
1use super::Operation;
2
3use crate::stmt;
4
5#[derive(Debug, Clone)]
6pub struct QuerySql {
7 /// The SQL query to execute
8 pub stmt: stmt::Statement,
9
10 /// The return type
11 pub ret: Option<Vec<stmt::Type>>,
12
13 /// **TEMPORARY HACK**: MySQL-specific workaround for RETURNING from INSERT.
14 ///
15 /// When set, indicates this query should be preceded by fetching LAST_INSERT_ID()
16 /// to simulate RETURNING behavior for the specified number of inserted rows.
17 /// The query will return a list of rows, each with a single column containing
18 /// the auto-increment ID.
19 ///
20 /// Non-MySQL drivers should assert this is None.
21 pub last_insert_id_hack: Option<u64>,
22}
23
24impl Operation {
25 /// Returns `true` if this is a [`QuerySql`](Operation::QuerySql) operation.
26 pub fn is_query_sql(&self) -> bool {
27 matches!(self, Operation::QuerySql(_))
28 }
29}
30
31impl From<QuerySql> for Operation {
32 fn from(value: QuerySql) -> Self {
33 Self::QuerySql(value)
34 }
35}