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