Skip to main content

sqlx_cloudflare_d1/
statement.rs

1use sqlx_core::sql_str::SqlStr;
2use sqlx_core::statement::Statement;
3use sqlx_core::Either;
4
5use crate::{D1Arguments, D1Column, D1TypeInfo, D1};
6
7/// A "prepared" D1 statement: the SQL and nothing else.
8///
9/// D1 has no server-side 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 D1Statement {
14    pub(crate) sql: SqlStr,
15}
16
17impl Statement for D1Statement {
18    type Database = D1;
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<&[D1TypeInfo], usize>> {
29        None
30    }
31
32    fn columns(&self) -> &[D1Column] {
33        &[]
34    }
35
36    sqlx_core::impl_statement_query!(D1Arguments);
37}