sqlx_core_oldapi/any/
mod.rs

1//! Generic database driver with the specific driver selected at runtime.
2
3use crate::executor::Executor;
4
5#[macro_use]
6mod decode;
7
8#[macro_use]
9mod encode;
10
11#[macro_use]
12mod r#type;
13
14mod arguments;
15pub(crate) mod column;
16mod connection;
17mod database;
18mod error;
19mod kind;
20mod options;
21mod query_result;
22pub(crate) mod row;
23mod statement;
24mod transaction;
25pub(crate) mod type_info;
26pub mod types;
27pub(crate) mod value;
28
29#[cfg(feature = "migrate")]
30mod migrate;
31
32pub use arguments::{AnyArgumentBuffer, AnyArguments};
33pub use column::{AnyColumn, AnyColumnIndex};
34pub use connection::AnyConnection;
35// Used internally in `sqlx-macros`
36#[doc(hidden)]
37pub use connection::AnyConnectionKind;
38pub use database::Any;
39pub use decode::AnyDecode;
40pub use encode::AnyEncode;
41pub use kind::AnyKind;
42pub use options::AnyConnectOptions;
43pub use query_result::AnyQueryResult;
44pub use row::AnyRow;
45pub use statement::AnyStatement;
46pub use transaction::AnyTransactionManager;
47pub use type_info::{AnyTypeInfo, AnyTypeInfoKind};
48pub use value::{AnyValue, AnyValueRef};
49
50pub type AnyPool = crate::pool::Pool<Any>;
51
52pub type AnyPoolOptions = crate::pool::PoolOptions<Any>;
53
54/// An alias for [`Executor<'_, Database = Any>`][Executor].
55pub trait AnyExecutor<'c>: Executor<'c, Database = Any> {}
56impl<'c, T: Executor<'c, Database = Any>> AnyExecutor<'c> for T {}
57
58// NOTE: required due to the lack of lazy normalization
59impl_into_arguments_for_arguments!(AnyArguments<'q>);
60impl_executor_for_pool_connection!(Any, AnyConnection, AnyRow);
61impl_executor_for_transaction!(Any, AnyRow);
62impl_acquire!(Any, AnyConnection);
63impl_column_index_for_row!(AnyRow);
64impl_column_index_for_statement!(AnyStatement);
65impl_into_maybe_pool!(Any, AnyConnection);
66
67// required because some databases have a different handling of NULL
68impl<'q, T> crate::encode::Encode<'q, Any> for Option<T>
69where
70    T: AnyEncode<'q> + 'q,
71{
72    fn encode_by_ref(&self, buf: &mut AnyArgumentBuffer<'q>) -> crate::encode::IsNull {
73        match &mut buf.0 {
74            #[cfg(feature = "postgres")]
75            arguments::AnyArgumentBufferKind::Postgres(args, _) => args.add(self),
76
77            #[cfg(feature = "mysql")]
78            arguments::AnyArgumentBufferKind::MySql(args, _) => args.add(self),
79
80            #[cfg(feature = "mssql")]
81            arguments::AnyArgumentBufferKind::Mssql(args, _) => args.add(self),
82
83            #[cfg(feature = "sqlite")]
84            arguments::AnyArgumentBufferKind::Sqlite(args) => args.add(self),
85        }
86
87        // unused
88        crate::encode::IsNull::No
89    }
90}