Skip to main content

sea_schema/postgres/discovery/executor/
mock.rs

1use crate::{
2    Connection,
3    sqlx_types::{PgPool, SqlxRow},
4};
5use sea_query::{PostgresQueryBuilder, SelectStatement};
6
7use crate::{debug_print, sqlx_types::SqlxError};
8
9#[allow(dead_code)]
10pub struct Executor {}
11
12pub trait IntoExecutor {
13    fn into_executor(self) -> Executor;
14}
15
16impl IntoExecutor for PgPool {
17    fn into_executor(self) -> Executor {
18        Executor {}
19    }
20}
21
22#[async_trait::async_trait(?Send)]
23impl Connection for Executor {
24    async fn query_all(&self, select: SelectStatement) -> Result<Vec<SqlxRow>, SqlxError> {
25        let (_sql, _values) = select.build(PostgresQueryBuilder);
26        debug_print!("{}, {:?}", _sql, _values);
27
28        panic!("This is a mock Executor");
29    }
30
31    async fn query_all_raw(&self, _sql: String) -> Result<Vec<SqlxRow>, SqlxError> {
32        debug_print!("{}", _sql);
33
34        panic!("This is a mock Executor");
35    }
36}