#[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;
pub mod common;
#[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,
_enum_variants: Option<&[&str]>,
) -> 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,
_enum_variants,
),
#[cfg(feature = "postgresql")]
DbType::PostgreSQL => {
crate::abstract_layer::postgresql_backend::PostgreSQLTypeMapper::sql_type(
_rust_type,
_is_primary,
_is_auto_increment,
_is_nullable,
_enum_variants,
)
}
#[cfg(feature = "mysql")]
DbType::MySQL => crate::abstract_layer::mysql_backend::MySQLTypeMapper::sql_type(
_rust_type,
_is_primary,
_is_auto_increment,
_is_nullable,
_enum_variants,
),
#[cfg(not(any(feature = "turso", feature = "postgresql", feature = "mysql")))]
DbType::None => {
String::new()
}
}
}
}
#[cfg(any(feature = "turso", feature = "postgresql", feature = "mysql"))]
pub use common::{
AggregateFuture, CollectFuture, CreateTableExecutor, Database, DeleteExecutor,
DropTableExecutor, GroupedCollectFuture, GroupedSelectExecutor, InsertExecutor,
InsertOrUpdateExecutor, LeftJoinCollectFuture, LeftJoinedSelectExecutor, MappedCollectFuture,
MappedSelectExecutor, ModelCollectWithFuture, RelatedCollectFuture, RelatedSelectExecutor,
SelectExecutor, SelectStream, SelectStreamIterator, Transaction, TransactionInsertExecutor,
TransactionInsertOrUpdateExecutor, UpdateExecutor,
};
#[cfg(any(feature = "turso", feature = "postgresql", feature = "mysql"))]
pub use common::{ConnectionPool, PooledConnection};