#[cfg(any(feature = "turso", feature = "postgresql", feature = "mysql"))]
use crate::model::DbBackendTypeMapper;
#[cfg(feature = "turso")]
pub mod turso_backend;
#[cfg(feature = "postgresql")]
pub mod postgresql_backend;
#[cfg(feature = "mysql")]
pub mod mysql_backend;
#[cfg(any(feature = "turso", feature = "postgresql", feature = "mysql"))]
pub mod connection_pool;
pub mod common_helpers;
#[macro_use]
pub mod macros;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum DbType {
#[cfg(feature = "turso")]
Turso,
#[cfg(feature = "postgresql")]
PostgreSQL,
#[cfg(feature = "mysql")]
MySQL,
#[cfg(not(any(feature = "turso", feature = "postgresql", feature = "mysql")))]
None,
}
impl DbType {
pub fn sql_type(
&self,
_rust_type: &str,
_is_primary: bool,
_is_auto_increment: bool,
_is_nullable: bool,
) -> String {
match self {
#[cfg(feature = "turso")]
DbType::Turso => crate::abstract_layer::turso_backend::TursoTypeMapper::sql_type(
_rust_type,
_is_primary,
_is_auto_increment,
_is_nullable,
),
#[cfg(feature = "postgresql")]
DbType::PostgreSQL => {
crate::abstract_layer::postgresql_backend::PostgreSQLTypeMapper::sql_type(
_rust_type,
_is_primary,
_is_auto_increment,
_is_nullable,
)
}
#[cfg(feature = "mysql")]
DbType::MySQL => crate::abstract_layer::mysql_backend::MySQLTypeMapper::sql_type(
_rust_type,
_is_primary,
_is_auto_increment,
_is_nullable,
),
#[cfg(not(any(feature = "turso", feature = "postgresql", feature = "mysql")))]
DbType::None => {
String::new()
}
}
}
}
#[cfg(any(feature = "turso", feature = "postgresql", feature = "mysql"))]
mod unified;
#[cfg(any(feature = "turso", feature = "postgresql", feature = "mysql"))]
pub use unified::{
AggregateFuture, CollectFuture, CreateTableExecutor, Database, DeleteExecutor,
DropTableExecutor, LeftJoinCollectFuture, LeftJoinedSelectExecutor, MappedCollectFuture,
MappedSelectExecutor, ModelCollectWithFuture, RelatedCollectFuture, RelatedSelectExecutor,
SelectExecutor, Transaction, UpdateExecutor,
};
#[cfg(any(feature = "turso", feature = "postgresql", feature = "mysql"))]
pub use connection_pool::{ConnectionPool, PooledConnection};