sqlx_core_oldapi/odbc/connection/
executor.rs1use crate::describe::Describe;
2use crate::error::Error;
3use crate::executor::{Execute, Executor};
4use crate::odbc::{Odbc, OdbcConnection, OdbcQueryResult, OdbcRow, OdbcStatement, OdbcTypeInfo};
5use either::Either;
6use futures_core::future::BoxFuture;
7use futures_core::stream::BoxStream;
8use futures_util::{future, FutureExt, StreamExt};
9
10impl<'c> Executor<'c> for &'c mut OdbcConnection {
13 type Database = Odbc;
14
15 fn fetch_many<'e, 'q: 'e, E>(
16 self,
17 mut query: E,
18 ) -> BoxStream<'e, Result<Either<OdbcQueryResult, OdbcRow>, Error>>
19 where
20 'c: 'e,
21 E: Execute<'q, Self::Database> + 'q,
22 {
23 let args = query.take_arguments();
24 Box::pin(self.execute_stream(query.sql(), args).into_stream())
25 }
26
27 fn fetch_optional<'e, 'q: 'e, E>(
28 self,
29 query: E,
30 ) -> BoxFuture<'e, Result<Option<OdbcRow>, Error>>
31 where
32 'c: 'e,
33 E: Execute<'q, Self::Database> + 'q,
34 {
35 Box::pin(self.fetch_many(query).into_future().then(|(v, _)| match v {
36 Some(Ok(Either::Right(r))) => future::ok(Some(r)),
37 Some(Ok(Either::Left(_))) => future::ok(None),
38 Some(Err(e)) => future::err(e),
39 None => future::ok(None),
40 }))
41 }
42
43 fn prepare_with<'e, 'q: 'e>(
44 self,
45 sql: &'q str,
46 _parameters: &'e [OdbcTypeInfo],
47 ) -> BoxFuture<'e, Result<OdbcStatement<'q>, Error>>
48 where
49 'c: 'e,
50 {
51 Box::pin(async move { self.prepare(sql).await })
52 }
53
54 #[doc(hidden)]
55 fn describe<'e, 'q: 'e>(self, _sql: &'q str) -> BoxFuture<'e, Result<Describe<Odbc>, Error>>
56 where
57 'c: 'e,
58 {
59 Box::pin(async move { Err(Error::Protocol("ODBC describe not implemented".into())) })
60 }
61}