diesel/sqlite/
backend.rs

1//! The SQLite backend
2
3use super::connection::{SqliteBindCollector, SqliteValue};
4use super::query_builder::SqliteQueryBuilder;
5use crate::backend::*;
6use crate::sql_types::TypeMetadata;
7
8/// The SQLite backend
9#[derive(#[automatically_derived]
impl ::core::fmt::Debug for Sqlite {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f, "Sqlite")
    }
}Debug, #[automatically_derived]
impl ::core::marker::Copy for Sqlite { }Copy, #[automatically_derived]
impl ::core::clone::Clone for Sqlite {
    #[inline]
    fn clone(&self) -> Sqlite { *self }
}Clone, #[automatically_derived]
impl ::core::hash::Hash for Sqlite {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {}
}Hash, #[automatically_derived]
impl ::core::cmp::PartialEq for Sqlite {
    #[inline]
    fn eq(&self, other: &Sqlite) -> bool { true }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for Sqlite {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_receiver_is_total_eq(&self) -> () {}
}Eq, #[automatically_derived]
impl ::core::default::Default for Sqlite {
    #[inline]
    fn default() -> Sqlite { Sqlite {} }
}Default)]
10pub struct Sqlite;
11
12/// Determines how a bind parameter is given to SQLite
13///
14/// Diesel deals with bind parameters after serialization as opaque blobs of
15/// bytes. However, SQLite instead has several functions where it expects the
16/// relevant C types.
17///
18/// The variants of this struct determine what bytes are expected from
19/// `ToSql` impls.
20#[allow(missing_debug_implementations)]
21#[derive(#[automatically_derived]
#[allow(missing_debug_implementations)]
impl ::core::fmt::Debug for SqliteType {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                SqliteType::Binary => "Binary",
                SqliteType::Text => "Text",
                SqliteType::Float => "Float",
                SqliteType::Double => "Double",
                SqliteType::SmallInt => "SmallInt",
                SqliteType::Integer => "Integer",
                SqliteType::Long => "Long",
            })
    }
}Debug, #[automatically_derived]
#[allow(missing_debug_implementations)]
impl ::core::hash::Hash for SqliteType {
    #[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 SqliteType {
    #[inline]
    fn eq(&self, other: &SqliteType) -> 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 SqliteType {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_receiver_is_total_eq(&self) -> () {}
}Eq, #[automatically_derived]
#[allow(missing_debug_implementations)]
impl ::core::clone::Clone for SqliteType {
    #[inline]
    fn clone(&self) -> SqliteType { *self }
}Clone, #[automatically_derived]
#[allow(missing_debug_implementations)]
impl ::core::marker::Copy for SqliteType { }Copy)]
22pub enum SqliteType {
23    /// Bind using `sqlite3_bind_blob`
24    Binary,
25    /// Bind using `sqlite3_bind_text`
26    Text,
27    /// `bytes` should contain an `f32`
28    Float,
29    /// `bytes` should contain an `f64`
30    Double,
31    /// `bytes` should contain an `i16`
32    SmallInt,
33    /// `bytes` should contain an `i32`
34    Integer,
35    /// `bytes` should contain an `i64`
36    Long,
37}
38
39impl Backend for Sqlite {
40    type QueryBuilder = SqliteQueryBuilder;
41    type RawValue<'a> = SqliteValue<'a, 'a, 'a>;
42    type BindCollector<'a> = SqliteBindCollector<'a>;
43}
44
45impl TypeMetadata for Sqlite {
46    type TypeMetadata = SqliteType;
47    type MetadataLookup = ();
48}
49
50impl SqlDialect for Sqlite {
51    #[cfg(not(feature = "returning_clauses_for_sqlite_3_35"))]
52    type ReturningClause = sql_dialect::returning_clause::DoesNotSupportReturningClause;
53    #[cfg(feature = "returning_clauses_for_sqlite_3_35")]
54    type ReturningClause = SqliteReturningClause;
55
56    type OnConflictClause = SqliteOnConflictClause;
57
58    type InsertWithDefaultKeyword =
59        sql_dialect::default_keyword_for_insert::DoesNotSupportDefaultKeyword;
60    type BatchInsertSupport = SqliteBatchInsert;
61    type ConcatClause = sql_dialect::concat_clause::ConcatWithPipesClause;
62    type DefaultValueClauseForInsert = sql_dialect::default_value_clause::AnsiDefaultValueClause;
63
64    type EmptyFromClauseSyntax = sql_dialect::from_clause_syntax::AnsiSqlFromClauseSyntax;
65    type SelectStatementSyntax = sql_dialect::select_statement_syntax::AnsiSqlSelectStatement;
66
67    type ExistsSyntax = sql_dialect::exists_syntax::AnsiSqlExistsSyntax;
68    type ArrayComparison = sql_dialect::array_comparison::AnsiSqlArrayComparison;
69    type AliasSyntax = sql_dialect::alias_syntax::AsAliasSyntax;
70
71    type WindowFrameClauseGroupSupport =
72        sql_dialect::window_frame_clause_group_support::IsoGroupWindowFrameUnit;
73    type WindowFrameExclusionSupport =
74        sql_dialect::window_frame_exclusion_support::FrameExclusionSupport;
75    type AggregateFunctionExpressions =
76        sql_dialect::aggregate_function_expressions::PostgresLikeAggregateFunctionExpressions;
77    type BuiltInWindowFunctionRequireOrder =
78        sql_dialect::built_in_window_function_require_order::NoOrderRequired;
79}
80
81impl DieselReserveSpecialization for Sqlite {}
82impl TrustedBackend for Sqlite {}
83
84#[derive(#[automatically_derived]
impl ::core::fmt::Debug for SqliteOnConflictClause {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f, "SqliteOnConflictClause")
    }
}Debug, #[automatically_derived]
impl ::core::marker::Copy for SqliteOnConflictClause { }Copy, #[automatically_derived]
impl ::core::clone::Clone for SqliteOnConflictClause {
    #[inline]
    fn clone(&self) -> SqliteOnConflictClause { *self }
}Clone)]
85pub struct SqliteOnConflictClause;
86
87impl sql_dialect::on_conflict_clause::SupportsOnConflictClause for SqliteOnConflictClause {}
88impl sql_dialect::on_conflict_clause::SupportsOnConflictClauseWhere for SqliteOnConflictClause {}
89impl sql_dialect::on_conflict_clause::PgLikeOnConflictClause for SqliteOnConflictClause {}
90
91#[derive(#[automatically_derived]
impl ::core::fmt::Debug for SqliteBatchInsert {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f, "SqliteBatchInsert")
    }
}Debug, #[automatically_derived]
impl ::core::marker::Copy for SqliteBatchInsert { }Copy, #[automatically_derived]
impl ::core::clone::Clone for SqliteBatchInsert {
    #[inline]
    fn clone(&self) -> SqliteBatchInsert { *self }
}Clone)]
92pub struct SqliteBatchInsert;
93
94#[derive(#[automatically_derived]
impl ::core::fmt::Debug for SqliteReturningClause {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f, "SqliteReturningClause")
    }
}Debug, #[automatically_derived]
impl ::core::marker::Copy for SqliteReturningClause { }Copy, #[automatically_derived]
impl ::core::clone::Clone for SqliteReturningClause {
    #[inline]
    fn clone(&self) -> SqliteReturningClause { *self }
}Clone)]
95pub struct SqliteReturningClause;
96
97impl sql_dialect::returning_clause::SupportsReturningClause for SqliteReturningClause {}