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