| 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. |
| 6 | use crate::executor::Executor; |
| 7 | |
| 8 | mod arguments; |
| 9 | pub(crate) mod column; |
| 10 | mod connection; |
| 11 | mod database; |
| 12 | mod error; |
| 13 | mod kind; |
| 14 | mod options; |
| 15 | mod query_result; |
| 16 | pub(crate) mod row; |
| 17 | mod statement; |
| 18 | mod transaction; |
| 19 | pub(crate) mod type_info; |
| 20 | pub mod types; |
| 21 | pub(crate) mod value; |
| 22 | |
| 23 | pub mod driver; |
| 24 | |
| 25 | #[cfg(feature = "migrate")] |
| 26 | mod migrate; |
| 27 | |
| 28 | pub use arguments::{AnyArgumentBuffer, AnyArguments}; |
| 29 | pub use column::AnyColumn; |
| 30 | pub use connection::AnyConnection; |
| 31 | // Used internally in `sqlx-macros` |
| 32 | |
| 33 | use crate::encode::Encode; |
| 34 | pub use connection::AnyConnectionBackend; |
| 35 | pub use database::Any; |
| 36 | #[allow(deprecated)] |
| 37 | pub use kind::AnyKind; |
| 38 | pub use options::AnyConnectOptions; |
| 39 | pub use query_result::AnyQueryResult; |
| 40 | pub use row::AnyRow; |
| 41 | pub use statement::AnyStatement; |
| 42 | pub use transaction::AnyTransactionManager; |
| 43 | pub use type_info::{AnyTypeInfo, AnyTypeInfoKind}; |
| 44 | pub use value::{AnyValue, AnyValueRef}; |
| 45 | |
| 46 | use crate::types::Type; |
| 47 | #[doc(hidden)] |
| 48 | pub use value::AnyValueKind; |
| 49 | |
| 50 | pub type AnyPool = crate::pool::Pool<Any>; |
| 51 | |
| 52 | pub type AnyPoolOptions = crate::pool::PoolOptions<Any>; |
| 53 | |
| 54 | /// An alias for [`Executor<'_, Database = Any>`][Executor]. |
| 55 | pub trait AnyExecutor<'c>: Executor<'c, Database = Any> {} |
| 56 | impl<'c, T: Executor<'c, Database = Any>> AnyExecutor<'c> for T {} |
| 57 | |
| 58 | // NOTE: required due to the lack of lazy normalization |
| 59 | impl_into_arguments_for_arguments!(AnyArguments<'q>); |
| 60 | // impl_executor_for_pool_connection!(Any, AnyConnection, AnyRow); |
| 61 | // impl_executor_for_transaction!(Any, AnyRow); |
| 62 | impl_acquire!(Any, AnyConnection); |
| 63 | impl_column_index_for_row!(AnyRow); |
| 64 | impl_column_index_for_statement!(AnyStatement); |
| 65 | // impl_into_maybe_pool!(Any, AnyConnection); |
| 66 | |
| 67 | // required because some databases have a different handling of NULL |
| 68 | impl<'q, T> Encode<'q, Any> for Option<T> |
| 69 | where |
| 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 | } |