diesel/mysql/
backend.rs

1//! The MySQL backend
2
3use super::query_builder::MysqlQueryBuilder;
4use super::MysqlValue;
5use crate::backend::sql_dialect::on_conflict_clause::SupportsOnConflictClause;
6use crate::backend::*;
7use crate::internal::derives::multiconnection::sql_dialect;
8use crate::query_builder::bind_collector::RawBytesBindCollector;
9use crate::sql_types::TypeMetadata;
10
11/// The MySQL backend
12#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq, Default)]
13pub struct Mysql;
14
15#[allow(missing_debug_implementations)]
16/// Represents possible types, that can be transmitted as via the
17/// Mysql wire protocol
18#[derive(Debug, Hash, PartialEq, Eq, Clone, Copy)]
19#[non_exhaustive]
20pub enum MysqlType {
21    /// A 8 bit signed integer
22    Tiny,
23    /// A 8 bit unsigned integer
24    UnsignedTiny,
25    /// A 16 bit signed integer
26    Short,
27    /// A 16 bit unsigned integer
28    UnsignedShort,
29    /// A 32 bit signed integer
30    Long,
31    /// A 32 bit unsigned integer
32    UnsignedLong,
33    /// A 64 bit signed integer
34    LongLong,
35    /// A 64 bit unsigned integer
36    UnsignedLongLong,
37    /// A 32 bit floating point number
38    Float,
39    /// A 64 bit floating point number
40    Double,
41    /// A fixed point decimal value
42    Numeric,
43    /// A datatype to store a time value
44    Time,
45    /// A datatype to store a date value
46    Date,
47    /// A datatype containing timestamp values ranging from
48    /// '1000-01-01 00:00:00' to '9999-12-31 23:59:59'.
49    DateTime,
50    /// A datatype containing timestamp values ranging from
51    /// 1970-01-01 00:00:01' UTC to '2038-01-19 03:14:07' UTC.
52    Timestamp,
53    /// A datatype for string values
54    String,
55    /// A datatype containing binary large objects
56    Blob,
57    /// A value containing a set of bit's
58    Bit,
59    /// A user defined set type
60    Set,
61    /// A user defined enum type
62    Enum,
63}
64
65impl Backend for Mysql {
66    type QueryBuilder = MysqlQueryBuilder;
67    type RawValue<'a> = MysqlValue<'a>;
68    type BindCollector<'a> = RawBytesBindCollector<Self>;
69}
70
71impl TypeMetadata for Mysql {
72    type TypeMetadata = MysqlType;
73    type MetadataLookup = ();
74}
75
76impl SqlDialect for Mysql {
77    type ReturningClause = sql_dialect::returning_clause::DoesNotSupportReturningClause;
78
79    type OnConflictClause = MysqlOnConflictClause;
80
81    type InsertWithDefaultKeyword = sql_dialect::default_keyword_for_insert::IsoSqlDefaultKeyword;
82    type BatchInsertSupport = sql_dialect::batch_insert_support::PostgresLikeBatchInsertSupport;
83    type DefaultValueClauseForInsert = MysqlStyleDefaultValueClause;
84
85    type EmptyFromClauseSyntax = sql_dialect::from_clause_syntax::AnsiSqlFromClauseSyntax;
86    type SelectStatementSyntax = sql_dialect::select_statement_syntax::AnsiSqlSelectStatement;
87
88    type ExistsSyntax = sql_dialect::exists_syntax::AnsiSqlExistsSyntax;
89    type ArrayComparison = sql_dialect::array_comparison::AnsiSqlArrayComparison;
90
91    type ConcatClause = MysqlConcatClause;
92    type AliasSyntax = sql_dialect::alias_syntax::AsAliasSyntax;
93
94    type WindowFrameClauseGroupSupport =
95        sql_dialect::window_frame_clause_group_support::NoGroupWindowFrameUnit;
96
97    type WindowFrameExclusionSupport =
98        sql_dialect::window_frame_exclusion_support::NoFrameFrameExclusionSupport;
99
100    type AggregateFunctionExpressions =
101        sql_dialect::aggregate_function_expressions::NoAggregateFunctionExpressions;
102
103    type BuiltInWindowFunctionRequireOrder = MysqlRequiresOrderForWindowFunctions;
104}
105
106impl DieselReserveSpecialization for Mysql {}
107impl TrustedBackend for Mysql {}
108
109#[derive(Debug, Clone, Copy)]
110pub struct MysqlStyleDefaultValueClause;
111
112#[derive(Debug, Clone, Copy)]
113pub struct MysqlConcatClause;
114
115#[derive(Debug, Clone, Copy)]
116pub struct MysqlOnConflictClause;
117
118#[derive(Debug, Clone, Copy)]
119pub struct MysqlRequiresOrderForWindowFunctions;
120
121impl SupportsOnConflictClause for MysqlOnConflictClause {}