Skip to main content

sqlx_cloudflare_do/
statement.rs

1use sqlx_core::sql_str::SqlStr;
2use sqlx_core::statement::Statement;
3use sqlx_core::Either;
4
5use crate::{Do, DoArguments, DoColumn, DoTypeInfo};
6
7/// A "prepared" Durable Object storage statement: the SQL and nothing else.
8///
9/// `sql.exec` has no separate prepare that reports parameters or columns, so there
10/// is nothing to learn by preparing ahead of time. This exists because sqlx's
11/// `Executor::prepare` has to return something.
12#[derive(Debug, Clone)]
13pub struct DoStatement {
14    pub(crate) sql: SqlStr,
15}
16
17impl Statement for DoStatement {
18    type Database = Do;
19
20    fn into_sql(self) -> SqlStr {
21        self.sql
22    }
23
24    fn sql(&self) -> &SqlStr {
25        &self.sql
26    }
27
28    fn parameters(&self) -> Option<Either<&[DoTypeInfo], usize>> {
29        None
30    }
31
32    fn columns(&self) -> &[DoColumn] {
33        &[]
34    }
35
36    sqlx_core::impl_statement_query!(DoArguments);
37}