sqlx_core/any/
mod.rs

1//! **SEE DOCUMENTATION BEFORE USE**. Generic database driver with the specific driver selected at runtime.
2//!
3//! The underlying database drivers are chosen at runtime from the list set via
4//! [`install_drivers`][self::driver::install_drivers]. Any use of `AnyConnection` or `AnyPool`
5//! without this will panic.
6use crate::executor::Executor;
7
8mod arguments;
9pub(crate) mod column;
10mod connection;
11mod database;
12mod error;
13mod kind;
14mod options;
15mod query_result;
16pub(crate) mod row;
17mod statement;
18mod transaction;
19pub(crate) mod type_info;
20pub mod types;
21pub(crate) mod value;
22
23pub mod driver;
24
25#[cfg(feature = "migrate")]
26mod migrate;
27
28pub use arguments::{AnyArgumentBuffer, AnyArguments};
29pub use column::AnyColumn;
30pub use connection::AnyConnection;
31// Used internally in `sqlx-macros`
32
33use crate::encode::Encode;
34pub use connection::AnyConnectionBackend;
35pub use database::Any;
36#[allow(deprecated)]
37pub use kind::AnyKind;
38pub use options::AnyConnectOptions;
39pub use query_result::AnyQueryResult;
40pub use row::AnyRow;
41pub use statement::AnyStatement;
42pub use transaction::AnyTransactionManager;
43pub use type_info::{AnyTypeInfo, AnyTypeInfoKind};
44pub use value::{AnyValue, AnyValueRef};
45
46use crate::types::Type;
47#[doc(hidden)]
48pub use value::AnyValueKind;
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>);
60// impl_executor_for_pool_connection!(Any, AnyConnection, AnyRow);
61// impl_executor_for_transaction!(Any, AnyRow);
62impl_acquire!(Any, AnyConnection);
63impl_column_index_for_row!(AnyRow);
64impl_column_index_for_statement!(AnyStatement);
65// impl_into_maybe_pool!(Any, AnyConnection);
66
67// required because some databases have a different handling of NULL
68impl<'q, T> Encode<'q, Any> for Option<T>
69where
70    T: Encode<'q, Any> + 'q + Type<Any>,
71{
72    fn encode_by_ref(
73        &self,
74        buf: &mut AnyArgumentBuffer<'q>,
75    ) -> Result<crate::encode::IsNull, crate::error::BoxDynError> {
76        if let Some(value) = self {
77            value.encode_by_ref(buf)
78        } else {
79            buf.0.push(AnyValueKind::Null(T::type_info().kind));
80            Ok(crate::encode::IsNull::Yes)
81        }
82    }
83}