1use super::MysqlQueryBuilder;
4use super::MysqlValue;
5use crate::backend::*;
6use crate::internal::derives::multiconnection::sql_dialect;
7use crate::mysql_like::MysqlType;
8use crate::mysql_like::query_fragments::MySqlLikeBatchUpdateSupport;
9use crate::mysql_like::query_fragments::{
10 MysqlConcatClause, MysqlOnConflictClause, MysqlRequiresOrderForWindowFunctions,
11 MysqlStyleDefaultValueClause,
12};
13use crate::mysql_like::{MapErrorNumber, MysqlLikeBackend};
14use crate::query_builder::bind_collector::RawBytesBindCollector;
15use crate::result::DatabaseErrorKind;
16use crate::sql_types::TypeMetadata;
17
18#[derive(#[automatically_derived]
impl ::core::fmt::Debug for Mysql {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f, "Mysql")
}
}Debug, #[automatically_derived]
impl ::core::marker::Copy for Mysql { }Copy, #[automatically_derived]
impl ::core::clone::Clone for Mysql {
#[inline]
fn clone(&self) -> Mysql { *self }
}Clone, #[automatically_derived]
impl ::core::hash::Hash for Mysql {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {}
}Hash, #[automatically_derived]
impl ::core::cmp::PartialEq for Mysql {
#[inline]
fn eq(&self, other: &Mysql) -> bool { true }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for Mysql {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {}
}Eq, #[automatically_derived]
impl ::core::default::Default for Mysql {
#[inline]
fn default() -> Mysql { Mysql {} }
}Default)]
20pub struct Mysql;
21
22impl Backend for Mysql {
23 type QueryBuilder = MysqlQueryBuilder;
24 type RawValue<'a> = MysqlValue<'a>;
25 type BindCollector<'a> = RawBytesBindCollector<Self>;
26}
27
28impl TypeMetadata for Mysql {
29 type TypeMetadata = MysqlType;
30 type MetadataLookup = ();
31}
32
33impl SqlDialect for Mysql {
34 type ReturningClause = sql_dialect::returning_clause::DoesNotSupportReturningClause;
35
36 type OnConflictClause = MysqlOnConflictClause;
37
38 type InsertWithDefaultKeyword = sql_dialect::default_keyword_for_insert::IsoSqlDefaultKeyword;
39 type BatchInsertSupport = sql_dialect::batch_insert_support::PostgresLikeBatchInsertSupport;
40 type DefaultValueClauseForInsert = MysqlStyleDefaultValueClause;
41
42 type BatchUpdateSupport = MySqlLikeBatchUpdateSupport;
43
44 type EmptyFromClauseSyntax = sql_dialect::from_clause_syntax::AnsiSqlFromClauseSyntax;
45 type SelectStatementSyntax = sql_dialect::select_statement_syntax::AnsiSqlSelectStatement;
46
47 type ExistsSyntax = sql_dialect::exists_syntax::AnsiSqlExistsSyntax;
48 type ArrayComparison = sql_dialect::array_comparison::AnsiSqlArrayComparison;
49
50 type ConcatClause = MysqlConcatClause;
51 type AliasSyntax = sql_dialect::alias_syntax::AsAliasSyntax;
52
53 type WindowFrameClauseGroupSupport =
54 sql_dialect::window_frame_clause_group_support::NoGroupWindowFrameUnit;
55
56 type WindowFrameExclusionSupport =
57 sql_dialect::window_frame_exclusion_support::NoFrameFrameExclusionSupport;
58
59 type AggregateFunctionExpressions =
60 sql_dialect::aggregate_function_expressions::NoAggregateFunctionExpressions;
61
62 type BuiltInWindowFunctionRequireOrder = MysqlRequiresOrderForWindowFunctions;
63}
64
65impl DieselReserveSpecialization for Mysql {}
66impl TrustedBackend for Mysql {}
67
68impl MysqlLikeBackend for Mysql {
69 const SCHEME: &'static str = "mysql";
70}
71
72impl MapErrorNumber for Mysql {
73 fn map_error_number(error_number: u32) -> crate::result::DatabaseErrorKind {
74 match error_number {
78 1062 | 1586 | 1859 => DatabaseErrorKind::UniqueViolation,
79 1216 | 1217 | 1451 | 1452 | 1830 | 1834 => DatabaseErrorKind::ForeignKeyViolation,
80 1792 => DatabaseErrorKind::ReadOnlyTransaction,
81 1048 | 1364 => DatabaseErrorKind::NotNullViolation,
82 3819 => DatabaseErrorKind::CheckViolation,
83 1213 => DatabaseErrorKind::SerializationFailure,
84 _ => DatabaseErrorKind::Unknown,
85 }
86 }
87}