use crate::query_builder::QueryBuilder;
use crate::sql_types::{self, HasSqlType, TypeMetadata};
#[cfg_attr(
not(any(
feature = "postgres_backend",
feature = "mysql_backend",
feature = "sqlite",
feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes"
)),
allow(unused_imports)
)]
#[doc(inline)]
#[diesel_derives::__diesel_public_if(
feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes"
)]
pub(crate) use self::private::{DieselReserveSpecialization, TrustedBackend};
#[cfg_attr(
feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes",
doc = "[`DieselReserveSpecialization`]"
)]
#[cfg_attr(
not(feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes"),
doc = "`DieselReserveSpecialization`"
)]
pub trait Backend
where
Self: Sized + SqlDialect + TypeMetadata,
Self: HasSqlType<sql_types::SmallInt>,
Self: HasSqlType<sql_types::Integer>,
Self: HasSqlType<sql_types::BigInt>,
Self: HasSqlType<sql_types::Float>,
Self: HasSqlType<sql_types::Double>,
Self: HasSqlType<sql_types::Text>,
Self: HasSqlType<sql_types::Binary>,
Self: HasSqlType<sql_types::Date>,
Self: HasSqlType<sql_types::Time>,
Self: HasSqlType<sql_types::Timestamp>,
{
type QueryBuilder: QueryBuilder<Self>;
type RawValue<'a>;
type BindCollector<'a>: crate::query_builder::bind_collector::BindCollector<'a, Self> + 'a;
}
#[doc(hidden)]
#[cfg(all(feature = "with-deprecated", not(feature = "without-deprecated")))]
#[deprecated(note = "Use `Backend::RawValue` directly")]
pub type RawValue<'a, DB> = <DB as Backend>::RawValue<'a>;
#[doc(hidden)]
#[cfg(all(feature = "with-deprecated", not(feature = "without-deprecated")))]
#[deprecated(note = "Use `Backend::BindCollector` directly")]
pub type BindCollector<'a, DB> = <DB as Backend>::BindCollector<'a>;
#[cfg_attr(
feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes",
doc = "See the [`sql_dialect`] module for options provided by diesel out of the box."
)]
pub trait SqlDialect: self::private::TrustedBackend {
#[cfg_attr(
feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes",
doc = "implementation for [`ReturningClause`](crate::query_builder::ReturningClause)"
)]
#[cfg_attr(
not(feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes"),
doc = "implementation for `ReturningClause`"
)]
#[cfg_attr(
feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes",
doc = "See [`sql_dialect::returning_clause`] for provided default implementations"
)]
type ReturningClause;
#[cfg_attr(
feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes",
doc = "See [`sql_dialect::on_conflict_clause`] for provided default implementations"
)]
type OnConflictClause;
#[cfg_attr(
feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes",
doc = "See [`sql_dialect::default_keyword_for_insert`] for provided default implementations"
)]
type InsertWithDefaultKeyword;
#[cfg_attr(
feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes",
doc = "implementation for [`BatchInsert`](crate::query_builder::BatchInsert)"
)]
#[cfg_attr(
not(feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes"),
doc = "implementation for `BatchInsert`"
)]
#[cfg_attr(
feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes",
doc = "See [`sql_dialect::batch_insert_support`] for provided default implementations"
)]
type BatchInsertSupport;
#[cfg_attr(
feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes",
doc = "implementation for [`Concat`](crate::expression::Concat)"
)]
#[cfg_attr(
not(feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes"),
doc = "implementation for `Concat`"
)]
#[cfg_attr(
feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes",
doc = "See [`sql_dialect::concat_clause`] for provided default implementations"
)]
type ConcatClause;
#[cfg_attr(
feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes",
doc = "implementation for [`DefaultValues`](crate::query_builder::DefaultValues)"
)]
#[cfg_attr(
not(feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes"),
doc = "implementation for `DefaultValues`"
)]
#[cfg_attr(
feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes",
doc = "See [`sql_dialect::default_value_clause`] for provided default implementations"
)]
type DefaultValueClauseForInsert;
#[cfg_attr(
feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes",
doc = "implementation for [`NoFromClause`](crate::query_builder::NoFromClause)"
)]
#[cfg_attr(
not(feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes"),
doc = "implementation for `NoFromClause`"
)]
#[cfg_attr(
feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes",
doc = "See [`sql_dialect::from_clause_syntax`] for provided default implementations"
)]
type EmptyFromClauseSyntax;
#[cfg_attr(
feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes",
doc = "implementation for [`Exists`](crate::expression::exists::Exists)"
)]
#[cfg_attr(
not(feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes"),
doc = "implementation for `Exists`"
)]
#[cfg_attr(
feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes",
doc = "See [`sql_dialect::exists_syntax`] for provided default implementations"
)]
type ExistsSyntax;
#[cfg_attr(
feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes",
doc = "implementations for [`In`](crate::expression::array_comparison::In),
[`NotIn`](crate::expression::array_comparison::NotIn) and
[`Many`](crate::expression::array_comparison::Many)"
)]
#[cfg_attr(
not(feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes"),
doc = "implementations for `In`, `NotIn` and `Many`"
)]
#[cfg_attr(
feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes",
doc = "See [`sql_dialect::array_comparison`] for provided default implementations"
)]
type ArrayComparison;
#[cfg_attr(
not(feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes"),
doc = "`SelectStatement` and `BoxedSelectStatement`"
)]
#[cfg_attr(
not(feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes"),
doc = "[`SelectStatement`](crate::query_builder::SelectStatement) and
[`BoxedSelectStatement`](crate::query_builder::BoxedSelectStatement)"
)]
#[cfg_attr(
feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes",
doc = "See [`sql_dialect::select_statement_syntax`] for provided default implementations"
)]
type SelectStatementSyntax;
#[cfg_attr(
feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes",
doc = "See [`sql_dialect::alias_syntax`] for provided default implementations"
)]
type AliasSyntax;
#[cfg_attr(
feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes",
doc = "See [`sql_dialect::window_frame_clause_group_support`] for provided default implementations"
)]
type WindowFrameClauseGroupSupport;
#[cfg_attr(
feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes",
doc = "See [`sql_dialect::window_frame_exclusion_support`] for provided default implementations"
)]
type WindowFrameExclusionSupport;
#[cfg_attr(
feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes",
doc = "See [`sql_dialect::window_frame_clause_group_support`] for provided default implementations"
)]
type AggregateFunctionExpressions;
#[cfg_attr(
feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes",
doc = "See [`sql_dialect::built_in_window_function_require_order`] for provided default implementations"
)]
type BuiltInWindowFunctionRequireOrder;
}
#[diesel_derives::__diesel_public_if(
feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes"
)]
pub(crate) mod sql_dialect {
#![cfg_attr(
not(feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes"),
// Otherwise there are false positives
// because the lint seems to believe that these pub statements
// are not required, but they are required through the various backend impls
allow(unreachable_pub)
)]
#[cfg(doc)]
use super::SqlDialect;
#[diesel_derives::__diesel_public_if(
feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes"
)]
pub mod on_conflict_clause {
pub trait SupportsOnConflictClause {}
pub trait SupportsOnConflictClauseWhere {}
pub trait PgLikeOnConflictClause: SupportsOnConflictClause {}
#[derive(Debug, Copy, Clone)]
pub struct DoesNotSupportOnConflictClause;
}
#[diesel_derives::__diesel_public_if(
feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes"
)]
pub mod returning_clause {
pub trait SupportsReturningClause {}
#[derive(Debug, Copy, Clone)]
pub struct PgLikeReturningClause;
#[derive(Debug, Copy, Clone)]
pub struct DoesNotSupportReturningClause;
impl SupportsReturningClause for PgLikeReturningClause {}
}
#[diesel_derives::__diesel_public_if(
feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes"
)]
pub mod default_keyword_for_insert {
pub trait SupportsDefaultKeyword {}
#[derive(Debug, Copy, Clone)]
pub struct IsoSqlDefaultKeyword;
#[derive(Debug, Copy, Clone)]
pub struct DoesNotSupportDefaultKeyword;
impl SupportsDefaultKeyword for IsoSqlDefaultKeyword {}
}
#[diesel_derives::__diesel_public_if(
feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes"
)]
pub mod batch_insert_support {
pub trait SupportsBatchInsert {}
#[derive(Debug, Copy, Clone)]
pub struct DoesNotSupportBatchInsert;
#[derive(Debug, Copy, Clone)]
pub struct PostgresLikeBatchInsertSupport;
impl SupportsBatchInsert for PostgresLikeBatchInsertSupport {}
}
#[diesel_derives::__diesel_public_if(
feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes"
)]
pub mod concat_clause {
#[derive(Debug, Clone, Copy)]
pub struct ConcatWithPipesClause;
}
#[diesel_derives::__diesel_public_if(
feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes"
)]
pub mod default_value_clause {
#[derive(Debug, Clone, Copy)]
pub struct AnsiDefaultValueClause;
}
#[diesel_derives::__diesel_public_if(
feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes"
)]
pub(crate) mod from_clause_syntax {
#[derive(Debug, Copy, Clone)]
pub struct AnsiSqlFromClauseSyntax;
}
#[diesel_derives::__diesel_public_if(
feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes"
)]
pub mod exists_syntax {
#[derive(Debug, Copy, Clone)]
pub struct AnsiSqlExistsSyntax;
}
#[diesel_derives::__diesel_public_if(
feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes"
)]
pub mod array_comparison {
#[derive(Debug, Copy, Clone)]
pub struct AnsiSqlArrayComparison;
}
#[diesel_derives::__diesel_public_if(
feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes"
)]
pub mod select_statement_syntax {
#[derive(Debug, Copy, Clone)]
pub struct AnsiSqlSelectStatement;
}
#[diesel_derives::__diesel_public_if(
feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes"
)]
pub mod alias_syntax {
#[derive(Debug, Copy, Clone)]
pub struct AsAliasSyntax;
}
#[diesel_derives::__diesel_public_if(
feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes"
)]
pub mod window_frame_clause_group_support {
#[derive(Debug, Copy, Clone)]
pub struct NoGroupWindowFrameUnit;
#[derive(Debug, Copy, Clone)]
pub struct IsoGroupWindowFrameUnit;
}
#[diesel_derives::__diesel_public_if(
feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes"
)]
pub mod aggregate_function_expressions {
#[derive(Debug, Copy, Clone)]
pub struct NoAggregateFunctionExpressions;
#[derive(Debug, Copy, Clone)]
pub struct PostgresLikeAggregateFunctionExpressions;
}
#[diesel_derives::__diesel_public_if(
feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes"
)]
pub mod window_frame_exclusion_support {
#[derive(Debug, Copy, Clone)]
pub struct FrameExclusionSupport;
#[derive(Debug, Copy, Clone)]
pub struct NoFrameFrameExclusionSupport;
}
#[diesel_derives::__diesel_public_if(
feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes"
)]
pub mod built_in_window_function_require_order {
#[derive(Debug, Copy, Clone)]
pub struct NoOrderRequired;
}
}
pub(crate) mod private {
#[cfg_attr(
diesel_docsrs,
doc(cfg(feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes"))
)]
pub trait DieselReserveSpecialization {}
#[cfg_attr(
diesel_docsrs,
doc(cfg(feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes"))
)]
pub trait TrustedBackend {}
}