Skip to main content

diesel/mysql/
backend.rs

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