use crate::model::DbBackendTypeMapper;
#[cfg(feature = "sqlite")]
pub mod sqlite_backend;
#[cfg(feature = "postgresql")]
pub mod postgresql_backend;
#[cfg(feature = "mysql")]
pub mod mysql_backend;
#[cfg(feature = "mssql")]
pub mod mssql_backend;
#[cfg(feature = "duckdb")]
pub mod duckdb_backend;
#[cfg(feature = "clickhouse")]
pub(crate) mod clickhouse_backend;
pub mod common;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum DbType {
#[cfg(feature = "sqlite")]
Sqlite,
#[cfg(feature = "postgresql")]
PostgreSQL,
#[cfg(feature = "mysql")]
MySQL,
#[cfg(feature = "mssql")]
MSSQL,
#[cfg(feature = "duckdb")]
DuckDB,
#[cfg(feature = "clickhouse")]
ClickHouse,
}
impl DbType {
pub fn is_transactional(&self) -> bool {
#[cfg(feature = "clickhouse")]
if matches!(self, DbType::ClickHouse) {
return false;
}
true
}
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 = "sqlite")]
DbType::Sqlite => crate::abstract_layer::sqlite_backend::SqliteTypeMapper::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(feature = "mssql")]
DbType::MSSQL => crate::abstract_layer::mssql_backend::MSSQLTypeMapper::sql_type(
_rust_type,
_is_primary,
_is_auto_increment,
_is_nullable,
_enum_variants,
),
#[cfg(feature = "duckdb")]
DbType::DuckDB => crate::abstract_layer::duckdb_backend::DuckDBTypeMapper::sql_type(
_rust_type,
_is_primary,
_is_auto_increment,
_is_nullable,
_enum_variants,
),
#[cfg(feature = "clickhouse")]
DbType::ClickHouse => {
crate::abstract_layer::clickhouse_backend::ClickHouseTypeMapper::sql_type(
_rust_type,
_is_primary,
_is_auto_increment,
_is_nullable,
_enum_variants,
)
}
}
}
}
pub use common::{
AggregateFuture, BatchFuture, BatchManyFuture, BatchQueries, BatchQuery, BatchQueryFuture,
CollectFuture, CreateTableExecutor, Database, DbExecutor, DeleteExecutor,
DerivedTableCollectFuture, DerivedTableSelectExecutor, DoubleIncludedCollectFuture,
DoubleIncludedSelectExecutor, DropTableExecutor, GroupedCollectFuture, GroupedSelectExecutor,
IncludedCollectFuture, IncludedSelectExecutor, InsertExecutor, InsertGraphExecutor,
InsertOrIgnoreExecutor, InsertOrUpdateExecutor, InsertPartialExecutor, IsolationLevel,
LeftJoinCollectFuture, LeftJoinedSelectExecutor, MappedCollectFuture, MappedSelectExecutor,
ModelCollectWithFuture, NestedInclude, PooledRawSelectExecutor, RawCollectFuture,
RawSelectExecutor, RelatedCollectFuture, RelatedSelectExecutor, RelationNestedLoader,
ReplicatedDatabase, ReplicatedDatabaseBuilder, SaveExecutor, ScopedDeleteExecutor,
ScopedUpdateExecutor, SelectExecutor, SelectStream, SelectStreamIterator, SingleSqlStatement,
SqlExecutor, SqlStatement, Transaction, TransactionFuture, TransactionInsertExecutor,
TransactionInsertOrIgnoreExecutor, TransactionInsertOrUpdateExecutor, TransactionOptions,
TransactionRawCollectFuture, TransactionRawSelectExecutor, TransactionSaveExecutor,
UpdateExecutor, UpdateGraphExecutor, WithoutHooksExecutor,
};
pub use common::{
ConnectionPool, PooledConnection, PooledDatabaseScope, ReplicatedConnectionPool,
ReplicatedPoolBuilder,
};