Skip to main content

diesel/sql_types/
mod.rs

1//! Types which represent a SQL data type.
2//!
3//! The structs in this module are *only* used as markers to represent a SQL type.
4//! They should never be used in your structs.
5//! If you'd like to know the rust types which can be used for a given SQL type,
6//! see the documentation for that SQL type.
7//! Additional types may be provided by other crates.
8//!
9//! To see which SQL type can be used with a given Rust type,
10//! see the "Implementors" section of [`FromSql`].
11//!
12//! [`FromSql`]: super::deserialize::FromSql
13//!
14//! Any backend specific types are re-exported through this module
15
16mod fold;
17pub mod ops;
18mod ord;
19
20pub use self::fold::Foldable;
21pub use self::ord::SqlOrd;
22
23use crate::backend::Backend;
24use crate::expression::TypedExpressionType;
25use crate::query_builder::QueryId;
26
27/// The boolean SQL type.
28///
29/// On backends without a native boolean type,
30/// this is emulated with the smallest supported integer.
31///
32/// ### [`ToSql`](crate::serialize::ToSql) impls
33///
34/// - [`bool`][bool]
35///
36/// ### [`FromSql`](crate::deserialize::FromSql) impls
37///
38/// - [`bool`][bool]
39///
40/// [bool]: https://doc.rust-lang.org/nightly/std/primitive.bool.html
41#[derive(#[automatically_derived]
impl ::core::fmt::Debug for Bool {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f, "Bool")
    }
}Debug, #[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for Bool { }
#[automatically_derived]
impl ::core::clone::Clone for Bool {
    #[inline]
    fn clone(&self) -> Bool { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for Bool { }Copy, #[automatically_derived]
impl ::core::default::Default for Bool {
    #[inline]
    fn default() -> Bool { Bool }
}Default, const _: () =
    {
        use diesel;
        #[allow(non_camel_case_types)]
        impl diesel::query_builder::QueryId for Bool {
            type QueryId = Bool<>;
            const HAS_STATIC_QUERY_ID: bool = true;
            const IS_WINDOW_FUNCTION: bool = false;
        }
    };QueryId, const _: () =
    {
        use diesel;
        impl diesel::sql_types::SqlType for Bool {
            type IsNull = diesel::sql_types::is_nullable::NotNull;
            const IS_ARRAY: bool = false;
        }
        impl diesel::sql_types::SingleValue for Bool {}
        impl diesel::sql_types::HasSqlType<Bool> for diesel::sqlite::Sqlite {
            fn metadata(_: &mut ()) -> diesel::sqlite::SqliteType {
                diesel::sqlite::SqliteType::Integer
            }
        }
        impl diesel::sql_types::HasSqlType<Bool> for diesel::mysql::Mysql {
            fn metadata(_: &mut ()) -> diesel::mysql::MysqlType {
                diesel::mysql::MysqlType::Tiny
            }
        }
        impl diesel::sql_types::HasSqlType<Bool> for diesel::mariadb::Mariadb
            {
            fn metadata(_: &mut ()) -> diesel::mariadb::MariadbType {
                diesel::mariadb::MariadbType::Tiny
            }
        }
        impl diesel::sql_types::HasSqlType<Bool> for diesel::pg::Pg {
            fn metadata(_: &mut Self::MetadataLookup)
                -> diesel::pg::PgTypeMetadata {
                diesel::pg::PgTypeMetadata::new(16, 1000)
            }
        }
    };SqlType)]
42#[diesel(postgres_type(oid = 16, array_oid = 1000))]
43#[diesel(sqlite_type(name = "Integer"))]
44#[diesel(mysql_type(name = "Tiny"))]
45#[diesel(mariadb_type(name = "Tiny"))]
46pub struct Bool;
47
48/// The tiny integer SQL type.
49///
50/// This is only available on MySQL.
51/// Keep in mind that `diesel print-schema` will see `TINYINT(1)` as `Bool`,
52/// not `TinyInt`.
53///
54/// ### [`ToSql`](crate::serialize::ToSql) impls
55///
56/// - [`i8`][i8]
57///
58/// ### [`FromSql`](crate::deserialize::FromSql) impls
59///
60/// - [`i8`][i8]
61///
62/// [i8]: https://doc.rust-lang.org/nightly/std/primitive.i8.html
63#[derive(#[automatically_derived]
impl ::core::fmt::Debug for TinyInt {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f, "TinyInt")
    }
}Debug, #[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for TinyInt { }
#[automatically_derived]
impl ::core::clone::Clone for TinyInt {
    #[inline]
    fn clone(&self) -> TinyInt { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for TinyInt { }Copy, #[automatically_derived]
impl ::core::default::Default for TinyInt {
    #[inline]
    fn default() -> TinyInt { TinyInt }
}Default, const _: () =
    {
        use diesel;
        #[allow(non_camel_case_types)]
        impl diesel::query_builder::QueryId for TinyInt {
            type QueryId = TinyInt<>;
            const HAS_STATIC_QUERY_ID: bool = true;
            const IS_WINDOW_FUNCTION: bool = false;
        }
    };QueryId, const _: () =
    {
        use diesel;
        impl diesel::sql_types::SqlType for TinyInt {
            type IsNull = diesel::sql_types::is_nullable::NotNull;
            const IS_ARRAY: bool = false;
        }
        impl diesel::sql_types::SingleValue for TinyInt {}
        impl diesel::sql_types::HasSqlType<TinyInt> for diesel::mysql::Mysql {
            fn metadata(_: &mut ()) -> diesel::mysql::MysqlType {
                diesel::mysql::MysqlType::Tiny
            }
        }
        impl diesel::sql_types::HasSqlType<TinyInt> for
            diesel::mariadb::Mariadb {
            fn metadata(_: &mut ()) -> diesel::mariadb::MariadbType {
                diesel::mariadb::MariadbType::Tiny
            }
        }
    };SqlType)]
64#[diesel(mysql_type(name = "Tiny"))]
65#[diesel(mariadb_type(name = "Tiny"))]
66pub struct TinyInt;
67#[doc(hidden)]
68pub type Tinyint = TinyInt;
69
70/// The small integer SQL type.
71///
72/// ### [`ToSql`](crate::serialize::ToSql) impls
73///
74/// - [`i16`][i16]
75///
76/// ### [`FromSql`](crate::deserialize::FromSql) impls
77///
78/// - [`i16`][i16]
79///
80/// [i16]: https://doc.rust-lang.org/nightly/std/primitive.i16.html
81#[derive(#[automatically_derived]
impl ::core::fmt::Debug for SmallInt {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f, "SmallInt")
    }
}Debug, #[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for SmallInt { }
#[automatically_derived]
impl ::core::clone::Clone for SmallInt {
    #[inline]
    fn clone(&self) -> SmallInt { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for SmallInt { }Copy, #[automatically_derived]
impl ::core::default::Default for SmallInt {
    #[inline]
    fn default() -> SmallInt { SmallInt }
}Default, const _: () =
    {
        use diesel;
        #[allow(non_camel_case_types)]
        impl diesel::query_builder::QueryId for SmallInt {
            type QueryId = SmallInt<>;
            const HAS_STATIC_QUERY_ID: bool = true;
            const IS_WINDOW_FUNCTION: bool = false;
        }
    };QueryId, const _: () =
    {
        use diesel;
        impl diesel::sql_types::SqlType for SmallInt {
            type IsNull = diesel::sql_types::is_nullable::NotNull;
            const IS_ARRAY: bool = false;
        }
        impl diesel::sql_types::SingleValue for SmallInt {}
        impl diesel::sql_types::HasSqlType<SmallInt> for
            diesel::sqlite::Sqlite {
            fn metadata(_: &mut ()) -> diesel::sqlite::SqliteType {
                diesel::sqlite::SqliteType::SmallInt
            }
        }
        impl diesel::sql_types::HasSqlType<SmallInt> for diesel::mysql::Mysql
            {
            fn metadata(_: &mut ()) -> diesel::mysql::MysqlType {
                diesel::mysql::MysqlType::Short
            }
        }
        impl diesel::sql_types::HasSqlType<SmallInt> for
            diesel::mariadb::Mariadb {
            fn metadata(_: &mut ()) -> diesel::mariadb::MariadbType {
                diesel::mariadb::MariadbType::Short
            }
        }
        impl diesel::sql_types::HasSqlType<SmallInt> for diesel::pg::Pg {
            fn metadata(_: &mut Self::MetadataLookup)
                -> diesel::pg::PgTypeMetadata {
                diesel::pg::PgTypeMetadata::new(21, 1005)
            }
        }
    };SqlType)]
82#[diesel(postgres_type(oid = 21, array_oid = 1005))]
83#[diesel(sqlite_type(name = "SmallInt"))]
84#[diesel(mysql_type(name = "Short"))]
85#[diesel(mariadb_type(name = "Short"))]
86pub struct SmallInt;
87#[doc(hidden)]
88pub type Int2 = SmallInt;
89#[doc(hidden)]
90pub type Smallint = SmallInt;
91
92/// The integer SQL type.
93///
94/// ### [`ToSql`](crate::serialize::ToSql) impls
95///
96/// - [`i32`][i32]
97///
98/// ### [`FromSql`](crate::deserialize::FromSql) impls
99///
100/// - [`i32`][i32]
101///
102/// [i32]: https://doc.rust-lang.org/nightly/std/primitive.i32.html
103#[derive(#[automatically_derived]
impl ::core::fmt::Debug for Integer {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f, "Integer")
    }
}Debug, #[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for Integer { }
#[automatically_derived]
impl ::core::clone::Clone for Integer {
    #[inline]
    fn clone(&self) -> Integer { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for Integer { }Copy, #[automatically_derived]
impl ::core::default::Default for Integer {
    #[inline]
    fn default() -> Integer { Integer }
}Default, const _: () =
    {
        use diesel;
        #[allow(non_camel_case_types)]
        impl diesel::query_builder::QueryId for Integer {
            type QueryId = Integer<>;
            const HAS_STATIC_QUERY_ID: bool = true;
            const IS_WINDOW_FUNCTION: bool = false;
        }
    };QueryId, const _: () =
    {
        use diesel;
        impl diesel::sql_types::SqlType for Integer {
            type IsNull = diesel::sql_types::is_nullable::NotNull;
            const IS_ARRAY: bool = false;
        }
        impl diesel::sql_types::SingleValue for Integer {}
        impl diesel::sql_types::HasSqlType<Integer> for diesel::sqlite::Sqlite
            {
            fn metadata(_: &mut ()) -> diesel::sqlite::SqliteType {
                diesel::sqlite::SqliteType::Integer
            }
        }
        impl diesel::sql_types::HasSqlType<Integer> for diesel::mysql::Mysql {
            fn metadata(_: &mut ()) -> diesel::mysql::MysqlType {
                diesel::mysql::MysqlType::Long
            }
        }
        impl diesel::sql_types::HasSqlType<Integer> for
            diesel::mariadb::Mariadb {
            fn metadata(_: &mut ()) -> diesel::mariadb::MariadbType {
                diesel::mariadb::MariadbType::Long
            }
        }
        impl diesel::sql_types::HasSqlType<Integer> for diesel::pg::Pg {
            fn metadata(_: &mut Self::MetadataLookup)
                -> diesel::pg::PgTypeMetadata {
                diesel::pg::PgTypeMetadata::new(23, 1007)
            }
        }
    };SqlType)]
104#[diesel(postgres_type(oid = 23, array_oid = 1007))]
105#[diesel(sqlite_type(name = "Integer"))]
106#[diesel(mysql_type(name = "Long"))]
107#[diesel(mariadb_type(name = "Long"))]
108pub struct Integer;
109#[doc(hidden)]
110pub type Int4 = Integer;
111
112/// The big integer SQL type.
113///
114/// ### [`ToSql`](crate::serialize::ToSql) impls
115///
116/// - [`i64`][i64]
117///
118/// ### [`FromSql`](crate::deserialize::FromSql) impls
119///
120/// - [`i64`][i64]
121///
122/// [i64]: https://doc.rust-lang.org/nightly/std/primitive.i64.html
123#[derive(#[automatically_derived]
impl ::core::fmt::Debug for BigInt {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f, "BigInt")
    }
}Debug, #[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for BigInt { }
#[automatically_derived]
impl ::core::clone::Clone for BigInt {
    #[inline]
    fn clone(&self) -> BigInt { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for BigInt { }Copy, #[automatically_derived]
impl ::core::default::Default for BigInt {
    #[inline]
    fn default() -> BigInt { BigInt }
}Default, const _: () =
    {
        use diesel;
        #[allow(non_camel_case_types)]
        impl diesel::query_builder::QueryId for BigInt {
            type QueryId = BigInt<>;
            const HAS_STATIC_QUERY_ID: bool = true;
            const IS_WINDOW_FUNCTION: bool = false;
        }
    };QueryId, const _: () =
    {
        use diesel;
        impl diesel::sql_types::SqlType for BigInt {
            type IsNull = diesel::sql_types::is_nullable::NotNull;
            const IS_ARRAY: bool = false;
        }
        impl diesel::sql_types::SingleValue for BigInt {}
        impl diesel::sql_types::HasSqlType<BigInt> for diesel::sqlite::Sqlite
            {
            fn metadata(_: &mut ()) -> diesel::sqlite::SqliteType {
                diesel::sqlite::SqliteType::Long
            }
        }
        impl diesel::sql_types::HasSqlType<BigInt> for diesel::mysql::Mysql {
            fn metadata(_: &mut ()) -> diesel::mysql::MysqlType {
                diesel::mysql::MysqlType::LongLong
            }
        }
        impl diesel::sql_types::HasSqlType<BigInt> for
            diesel::mariadb::Mariadb {
            fn metadata(_: &mut ()) -> diesel::mariadb::MariadbType {
                diesel::mariadb::MariadbType::LongLong
            }
        }
        impl diesel::sql_types::HasSqlType<BigInt> for diesel::pg::Pg {
            fn metadata(_: &mut Self::MetadataLookup)
                -> diesel::pg::PgTypeMetadata {
                diesel::pg::PgTypeMetadata::new(20, 1016)
            }
        }
    };SqlType)]
124#[diesel(postgres_type(oid = 20, array_oid = 1016))]
125#[diesel(sqlite_type(name = "Long"))]
126#[diesel(mysql_type(name = "LongLong"))]
127#[diesel(mariadb_type(name = "LongLong"))]
128pub struct BigInt;
129#[doc(hidden)]
130pub type Int8 = BigInt;
131#[doc(hidden)]
132pub type Bigint = BigInt;
133
134/// The float SQL type.
135///
136/// ### [`ToSql`](crate::serialize::ToSql) impls
137///
138/// - [`f32`][f32]
139///
140/// ### [`FromSql`](crate::deserialize::FromSql) impls
141///
142/// - [`f32`][f32]
143///
144/// [f32]: https://doc.rust-lang.org/nightly/std/primitive.f32.html
145#[derive(#[automatically_derived]
impl ::core::fmt::Debug for Float {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f, "Float")
    }
}Debug, #[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for Float { }
#[automatically_derived]
impl ::core::clone::Clone for Float {
    #[inline]
    fn clone(&self) -> Float { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for Float { }Copy, #[automatically_derived]
impl ::core::default::Default for Float {
    #[inline]
    fn default() -> Float { Float }
}Default, const _: () =
    {
        use diesel;
        #[allow(non_camel_case_types)]
        impl diesel::query_builder::QueryId for Float {
            type QueryId = Float<>;
            const HAS_STATIC_QUERY_ID: bool = true;
            const IS_WINDOW_FUNCTION: bool = false;
        }
    };QueryId, const _: () =
    {
        use diesel;
        impl diesel::sql_types::SqlType for Float {
            type IsNull = diesel::sql_types::is_nullable::NotNull;
            const IS_ARRAY: bool = false;
        }
        impl diesel::sql_types::SingleValue for Float {}
        impl diesel::sql_types::HasSqlType<Float> for diesel::sqlite::Sqlite {
            fn metadata(_: &mut ()) -> diesel::sqlite::SqliteType {
                diesel::sqlite::SqliteType::Float
            }
        }
        impl diesel::sql_types::HasSqlType<Float> for diesel::mysql::Mysql {
            fn metadata(_: &mut ()) -> diesel::mysql::MysqlType {
                diesel::mysql::MysqlType::Float
            }
        }
        impl diesel::sql_types::HasSqlType<Float> for diesel::mariadb::Mariadb
            {
            fn metadata(_: &mut ()) -> diesel::mariadb::MariadbType {
                diesel::mariadb::MariadbType::Float
            }
        }
        impl diesel::sql_types::HasSqlType<Float> for diesel::pg::Pg {
            fn metadata(_: &mut Self::MetadataLookup)
                -> diesel::pg::PgTypeMetadata {
                diesel::pg::PgTypeMetadata::new(700, 1021)
            }
        }
    };SqlType)]
146#[diesel(postgres_type(oid = 700, array_oid = 1021))]
147#[diesel(sqlite_type(name = "Float"))]
148#[diesel(mysql_type(name = "Float"))]
149#[diesel(mariadb_type(name = "Float"))]
150pub struct Float;
151#[doc(hidden)]
152pub type Float4 = Float;
153
154/// The double precision float SQL type.
155///
156/// ### [`ToSql`](crate::serialize::ToSql) impls
157///
158/// - [`f64`][f64]
159///
160/// ### [`FromSql`](crate::deserialize::FromSql) impls
161///
162/// - [`f64`][f64]
163///
164/// [f64]: https://doc.rust-lang.org/nightly/std/primitive.f64.html
165#[derive(#[automatically_derived]
impl ::core::fmt::Debug for Double {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f, "Double")
    }
}Debug, #[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for Double { }
#[automatically_derived]
impl ::core::clone::Clone for Double {
    #[inline]
    fn clone(&self) -> Double { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for Double { }Copy, #[automatically_derived]
impl ::core::default::Default for Double {
    #[inline]
    fn default() -> Double { Double }
}Default, const _: () =
    {
        use diesel;
        #[allow(non_camel_case_types)]
        impl diesel::query_builder::QueryId for Double {
            type QueryId = Double<>;
            const HAS_STATIC_QUERY_ID: bool = true;
            const IS_WINDOW_FUNCTION: bool = false;
        }
    };QueryId, const _: () =
    {
        use diesel;
        impl diesel::sql_types::SqlType for Double {
            type IsNull = diesel::sql_types::is_nullable::NotNull;
            const IS_ARRAY: bool = false;
        }
        impl diesel::sql_types::SingleValue for Double {}
        impl diesel::sql_types::HasSqlType<Double> for diesel::sqlite::Sqlite
            {
            fn metadata(_: &mut ()) -> diesel::sqlite::SqliteType {
                diesel::sqlite::SqliteType::Double
            }
        }
        impl diesel::sql_types::HasSqlType<Double> for diesel::mysql::Mysql {
            fn metadata(_: &mut ()) -> diesel::mysql::MysqlType {
                diesel::mysql::MysqlType::Double
            }
        }
        impl diesel::sql_types::HasSqlType<Double> for
            diesel::mariadb::Mariadb {
            fn metadata(_: &mut ()) -> diesel::mariadb::MariadbType {
                diesel::mariadb::MariadbType::Double
            }
        }
        impl diesel::sql_types::HasSqlType<Double> for diesel::pg::Pg {
            fn metadata(_: &mut Self::MetadataLookup)
                -> diesel::pg::PgTypeMetadata {
                diesel::pg::PgTypeMetadata::new(701, 1022)
            }
        }
    };SqlType)]
166#[diesel(postgres_type(oid = 701, array_oid = 1022))]
167#[diesel(sqlite_type(name = "Double"))]
168#[diesel(mysql_type(name = "Double"))]
169#[diesel(mariadb_type(name = "Double"))]
170pub struct Double;
171#[doc(hidden)]
172pub type Float8 = Double;
173
174/// The arbitrary precision numeric SQL type.
175///
176/// This type is only supported on PostgreSQL and MySQL.
177/// On SQLite, [`Double`] should be used instead.
178///
179/// ### [`ToSql`](crate::serialize::ToSql) impls
180///
181/// - [`bigdecimal::BigDecimal`] with `feature = ["numeric"]`
182///
183/// ### [`FromSql`](crate::deserialize::FromSql) impls
184///
185/// - [`bigdecimal::BigDecimal`] with `feature = ["numeric"]`
186///
187/// [`bigdecimal::BigDecimal`]: /bigdecimal/struct.BigDecimal.html
188#[derive(#[automatically_derived]
impl ::core::fmt::Debug for Numeric {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f, "Numeric")
    }
}Debug, #[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for Numeric { }
#[automatically_derived]
impl ::core::clone::Clone for Numeric {
    #[inline]
    fn clone(&self) -> Numeric { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for Numeric { }Copy, #[automatically_derived]
impl ::core::default::Default for Numeric {
    #[inline]
    fn default() -> Numeric { Numeric }
}Default, const _: () =
    {
        use diesel;
        #[allow(non_camel_case_types)]
        impl diesel::query_builder::QueryId for Numeric {
            type QueryId = Numeric<>;
            const HAS_STATIC_QUERY_ID: bool = true;
            const IS_WINDOW_FUNCTION: bool = false;
        }
    };QueryId, const _: () =
    {
        use diesel;
        impl diesel::sql_types::SqlType for Numeric {
            type IsNull = diesel::sql_types::is_nullable::NotNull;
            const IS_ARRAY: bool = false;
        }
        impl diesel::sql_types::SingleValue for Numeric {}
        impl diesel::sql_types::HasSqlType<Numeric> for diesel::sqlite::Sqlite
            {
            fn metadata(_: &mut ()) -> diesel::sqlite::SqliteType {
                diesel::sqlite::SqliteType::Double
            }
        }
        impl diesel::sql_types::HasSqlType<Numeric> for diesel::mysql::Mysql {
            fn metadata(_: &mut ()) -> diesel::mysql::MysqlType {
                diesel::mysql::MysqlType::Numeric
            }
        }
        impl diesel::sql_types::HasSqlType<Numeric> for
            diesel::mariadb::Mariadb {
            fn metadata(_: &mut ()) -> diesel::mariadb::MariadbType {
                diesel::mariadb::MariadbType::Numeric
            }
        }
        impl diesel::sql_types::HasSqlType<Numeric> for diesel::pg::Pg {
            fn metadata(_: &mut Self::MetadataLookup)
                -> diesel::pg::PgTypeMetadata {
                diesel::pg::PgTypeMetadata::new(1700, 1231)
            }
        }
    };SqlType)]
189#[diesel(postgres_type(oid = 1700, array_oid = 1231))]
190#[diesel(mysql_type(name = "Numeric"))]
191#[diesel(mariadb_type(name = "Numeric"))]
192#[diesel(sqlite_type(name = "Double"))]
193pub struct Numeric;
194
195/// Alias for `Numeric`
196pub type Decimal = Numeric;
197
198/// The text SQL type.
199///
200/// On all backends strings must be valid UTF-8.
201/// On PostgreSQL strings must not include nul bytes.
202///
203/// Schema inference will treat all variants of `TEXT` as this type (e.g.
204/// `VARCHAR`, `MEDIUMTEXT`, etc).
205///
206/// ### [`ToSql`](crate::serialize::ToSql) impls
207///
208/// - [`String`]
209/// - [`&str`][str]
210///
211/// ### [`FromSql`](crate::deserialize::FromSql) impls
212///
213/// - [`String`]
214///
215/// [str]: https://doc.rust-lang.org/nightly/std/primitive.str.html
216#[derive(#[automatically_derived]
impl ::core::fmt::Debug for Text {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f, "Text")
    }
}Debug, #[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for Text { }
#[automatically_derived]
impl ::core::clone::Clone for Text {
    #[inline]
    fn clone(&self) -> Text { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for Text { }Copy, #[automatically_derived]
impl ::core::default::Default for Text {
    #[inline]
    fn default() -> Text { Text }
}Default, const _: () =
    {
        use diesel;
        #[allow(non_camel_case_types)]
        impl diesel::query_builder::QueryId for Text {
            type QueryId = Text<>;
            const HAS_STATIC_QUERY_ID: bool = true;
            const IS_WINDOW_FUNCTION: bool = false;
        }
    };QueryId, const _: () =
    {
        use diesel;
        impl diesel::sql_types::SqlType for Text {
            type IsNull = diesel::sql_types::is_nullable::NotNull;
            const IS_ARRAY: bool = false;
        }
        impl diesel::sql_types::SingleValue for Text {}
        impl diesel::sql_types::HasSqlType<Text> for diesel::sqlite::Sqlite {
            fn metadata(_: &mut ()) -> diesel::sqlite::SqliteType {
                diesel::sqlite::SqliteType::Text
            }
        }
        impl diesel::sql_types::HasSqlType<Text> for diesel::mysql::Mysql {
            fn metadata(_: &mut ()) -> diesel::mysql::MysqlType {
                diesel::mysql::MysqlType::String
            }
        }
        impl diesel::sql_types::HasSqlType<Text> for diesel::mariadb::Mariadb
            {
            fn metadata(_: &mut ()) -> diesel::mariadb::MariadbType {
                diesel::mariadb::MariadbType::String
            }
        }
        impl diesel::sql_types::HasSqlType<Text> for diesel::pg::Pg {
            fn metadata(_: &mut Self::MetadataLookup)
                -> diesel::pg::PgTypeMetadata {
                diesel::pg::PgTypeMetadata::new(25, 1009)
            }
        }
    };SqlType)]
217#[diesel(postgres_type(oid = 25, array_oid = 1009))]
218#[diesel(sqlite_type(name = "Text"))]
219#[diesel(mysql_type(name = "String"))]
220#[diesel(mariadb_type(name = "String"))]
221pub struct Text;
222
223/// The SQL `VARCHAR` type
224///
225/// This type is generally interchangeable with `TEXT`, so Diesel has this as an
226/// alias rather than a separate type (Diesel does not currently support
227/// implicit coercions).
228///
229/// One notable exception to this is with arrays on PG. `TEXT[]` cannot be
230/// coerced to `VARCHAR[]`.  It is recommended that you always use `TEXT[]` if
231/// you need a string array on PG.
232pub type VarChar = Text;
233#[doc(hidden)]
234pub type Varchar = VarChar;
235#[doc(hidden)]
236pub type Char = Text;
237#[doc(hidden)]
238pub type Tinytext = Text;
239#[doc(hidden)]
240pub type Mediumtext = Text;
241#[doc(hidden)]
242pub type Longtext = Text;
243
244/// The binary SQL type.
245///
246/// Schema inference will treat all variants of `BLOB` as this type (e.g.
247/// `VARBINARY`, `MEDIUMBLOB`, etc).
248///
249/// ### [`ToSql`](crate::serialize::ToSql) impls
250///
251/// - [`Vec<u8>`][Vec]
252/// - [`&[u8]`][slice]
253///
254/// ### [`FromSql`](crate::deserialize::FromSql) impls
255///
256/// - [`Vec<u8>`][Vec]
257///
258/// [Vec]: std::vec::Vec
259/// [slice]: https://doc.rust-lang.org/nightly/std/primitive.slice.html
260#[derive(#[automatically_derived]
impl ::core::fmt::Debug for Binary {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f, "Binary")
    }
}Debug, #[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for Binary { }
#[automatically_derived]
impl ::core::clone::Clone for Binary {
    #[inline]
    fn clone(&self) -> Binary { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for Binary { }Copy, #[automatically_derived]
impl ::core::default::Default for Binary {
    #[inline]
    fn default() -> Binary { Binary }
}Default, const _: () =
    {
        use diesel;
        #[allow(non_camel_case_types)]
        impl diesel::query_builder::QueryId for Binary {
            type QueryId = Binary<>;
            const HAS_STATIC_QUERY_ID: bool = true;
            const IS_WINDOW_FUNCTION: bool = false;
        }
    };QueryId, const _: () =
    {
        use diesel;
        impl diesel::sql_types::SqlType for Binary {
            type IsNull = diesel::sql_types::is_nullable::NotNull;
            const IS_ARRAY: bool = false;
        }
        impl diesel::sql_types::SingleValue for Binary {}
        impl diesel::sql_types::HasSqlType<Binary> for diesel::sqlite::Sqlite
            {
            fn metadata(_: &mut ()) -> diesel::sqlite::SqliteType {
                diesel::sqlite::SqliteType::Binary
            }
        }
        impl diesel::sql_types::HasSqlType<Binary> for diesel::mysql::Mysql {
            fn metadata(_: &mut ()) -> diesel::mysql::MysqlType {
                diesel::mysql::MysqlType::Blob
            }
        }
        impl diesel::sql_types::HasSqlType<Binary> for
            diesel::mariadb::Mariadb {
            fn metadata(_: &mut ()) -> diesel::mariadb::MariadbType {
                diesel::mariadb::MariadbType::Blob
            }
        }
        impl diesel::sql_types::HasSqlType<Binary> for diesel::pg::Pg {
            fn metadata(_: &mut Self::MetadataLookup)
                -> diesel::pg::PgTypeMetadata {
                diesel::pg::PgTypeMetadata::new(17, 1001)
            }
        }
    };SqlType)]
261#[diesel(postgres_type(oid = 17, array_oid = 1001))]
262#[diesel(sqlite_type(name = "Binary"))]
263#[diesel(mysql_type(name = "Blob"))]
264#[diesel(mariadb_type(name = "Blob"))]
265pub struct Binary;
266
267#[doc(hidden)]
268pub type Tinyblob = Binary;
269#[doc(hidden)]
270pub type Blob = Binary;
271#[doc(hidden)]
272pub type Mediumblob = Binary;
273#[doc(hidden)]
274pub type Longblob = Binary;
275#[doc(hidden)]
276pub type Varbinary = Binary;
277#[doc(hidden)]
278pub type Bit = Binary;
279
280/// The date SQL type.
281///
282/// ### [`ToSql`](crate::serialize::ToSql) impls
283///
284/// - [`chrono::NaiveDate`][NaiveDate] with `feature = "chrono"`
285/// - [`time::Date`][Date] with `feature = "time"`
286///
287/// ### [`FromSql`](crate::deserialize::FromSql) impls
288///
289/// - [`chrono::NaiveDate`][NaiveDate] with `feature = "chrono"`
290/// - [`time::Date`][Date] with `feature = "time"`
291///
292/// [NaiveDate]: https://docs.rs/chrono/*/chrono/naive/struct.NaiveDate.html
293/// [Date]: https://docs.rs/time/0.3.9/time/struct.Date.html
294#[derive(#[automatically_derived]
impl ::core::fmt::Debug for Date {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f, "Date")
    }
}Debug, #[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for Date { }
#[automatically_derived]
impl ::core::clone::Clone for Date {
    #[inline]
    fn clone(&self) -> Date { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for Date { }Copy, #[automatically_derived]
impl ::core::default::Default for Date {
    #[inline]
    fn default() -> Date { Date }
}Default, const _: () =
    {
        use diesel;
        #[allow(non_camel_case_types)]
        impl diesel::query_builder::QueryId for Date {
            type QueryId = Date<>;
            const HAS_STATIC_QUERY_ID: bool = true;
            const IS_WINDOW_FUNCTION: bool = false;
        }
    };QueryId, const _: () =
    {
        use diesel;
        impl diesel::sql_types::SqlType for Date {
            type IsNull = diesel::sql_types::is_nullable::NotNull;
            const IS_ARRAY: bool = false;
        }
        impl diesel::sql_types::SingleValue for Date {}
        impl diesel::sql_types::HasSqlType<Date> for diesel::sqlite::Sqlite {
            fn metadata(_: &mut ()) -> diesel::sqlite::SqliteType {
                diesel::sqlite::SqliteType::Text
            }
        }
        impl diesel::sql_types::HasSqlType<Date> for diesel::mysql::Mysql {
            fn metadata(_: &mut ()) -> diesel::mysql::MysqlType {
                diesel::mysql::MysqlType::Date
            }
        }
        impl diesel::sql_types::HasSqlType<Date> for diesel::mariadb::Mariadb
            {
            fn metadata(_: &mut ()) -> diesel::mariadb::MariadbType {
                diesel::mariadb::MariadbType::Date
            }
        }
        impl diesel::sql_types::HasSqlType<Date> for diesel::pg::Pg {
            fn metadata(_: &mut Self::MetadataLookup)
                -> diesel::pg::PgTypeMetadata {
                diesel::pg::PgTypeMetadata::new(1082, 1182)
            }
        }
    };SqlType)]
295#[diesel(postgres_type(oid = 1082, array_oid = 1182))]
296#[diesel(sqlite_type(name = "Text"))]
297#[diesel(mysql_type(name = "Date"))]
298#[diesel(mariadb_type(name = "Date"))]
299pub struct Date;
300
301/// The interval SQL type.
302///
303/// This type is currently only implemented for PostgreSQL.
304///
305/// ### [`ToSql`](crate::serialize::ToSql) impls
306///
307/// - [`PgInterval`] which can be constructed using [`IntervalDsl`]
308/// - [`chrono::Duration`][Duration] with `feature = "chrono"`
309///
310/// ### [`FromSql`](crate::deserialize::FromSql) impls
311///
312/// - [`PgInterval`] which can be constructed using [`IntervalDsl`]
313/// - [`chrono::Duration`][Duration] with `feature = "chrono"`
314///   (There might be some information loss due to special behavior for literal `month` (or longer) intervals;
315///   Please read official documentation of [PostgreSQL Interval].)
316///
317/// [`PgInterval`]: ../pg/data_types/struct.PgInterval.html
318/// [`IntervalDsl`]: ../pg/expression/extensions/trait.IntervalDsl.html
319/// [Duration]: https://docs.rs/chrono/*/chrono/type.Duration.html
320/// [PostgreSQL Interval]: https://www.postgresql.org/docs/current/datatype-datetime.html#DATATYPE-INTERVAL-INPUT
321#[derive(#[automatically_derived]
impl ::core::fmt::Debug for Interval {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f, "Interval")
    }
}Debug, #[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for Interval { }
#[automatically_derived]
impl ::core::clone::Clone for Interval {
    #[inline]
    fn clone(&self) -> Interval { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for Interval { }Copy, #[automatically_derived]
impl ::core::default::Default for Interval {
    #[inline]
    fn default() -> Interval { Interval }
}Default, const _: () =
    {
        use diesel;
        #[allow(non_camel_case_types)]
        impl diesel::query_builder::QueryId for Interval {
            type QueryId = Interval<>;
            const HAS_STATIC_QUERY_ID: bool = true;
            const IS_WINDOW_FUNCTION: bool = false;
        }
    };QueryId, const _: () =
    {
        use diesel;
        impl diesel::sql_types::SqlType for Interval {
            type IsNull = diesel::sql_types::is_nullable::NotNull;
            const IS_ARRAY: bool = false;
        }
        impl diesel::sql_types::SingleValue for Interval {}
        impl diesel::sql_types::HasSqlType<Interval> for diesel::pg::Pg {
            fn metadata(_: &mut Self::MetadataLookup)
                -> diesel::pg::PgTypeMetadata {
                diesel::pg::PgTypeMetadata::new(1186, 1187)
            }
        }
    };SqlType)]
322#[diesel(postgres_type(oid = 1186, array_oid = 1187))]
323pub struct Interval;
324
325/// The time SQL type.
326///
327/// ### [`ToSql`](crate::serialize::ToSql) impls
328///
329/// - [`chrono::NaiveTime`][NaiveTime] with `feature = "chrono"`
330/// - [`time::Time`][Time] with `feature = "time"`
331///
332/// ### [`FromSql`](crate::deserialize::FromSql) impls
333///
334/// - [`chrono::NaiveTime`][NaiveTime] with `feature = "chrono"`
335/// - [`time::Time`][Time] with `feature = "time"`
336///
337/// [NaiveTime]: /chrono/naive/time/struct.NaiveTime.html
338/// [Time]: /time/struct.Time.html
339#[derive(#[automatically_derived]
impl ::core::fmt::Debug for Time {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f, "Time")
    }
}Debug, #[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for Time { }
#[automatically_derived]
impl ::core::clone::Clone for Time {
    #[inline]
    fn clone(&self) -> Time { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for Time { }Copy, #[automatically_derived]
impl ::core::default::Default for Time {
    #[inline]
    fn default() -> Time { Time }
}Default, const _: () =
    {
        use diesel;
        #[allow(non_camel_case_types)]
        impl diesel::query_builder::QueryId for Time {
            type QueryId = Time<>;
            const HAS_STATIC_QUERY_ID: bool = true;
            const IS_WINDOW_FUNCTION: bool = false;
        }
    };QueryId, const _: () =
    {
        use diesel;
        impl diesel::sql_types::SqlType for Time {
            type IsNull = diesel::sql_types::is_nullable::NotNull;
            const IS_ARRAY: bool = false;
        }
        impl diesel::sql_types::SingleValue for Time {}
        impl diesel::sql_types::HasSqlType<Time> for diesel::sqlite::Sqlite {
            fn metadata(_: &mut ()) -> diesel::sqlite::SqliteType {
                diesel::sqlite::SqliteType::Text
            }
        }
        impl diesel::sql_types::HasSqlType<Time> for diesel::mysql::Mysql {
            fn metadata(_: &mut ()) -> diesel::mysql::MysqlType {
                diesel::mysql::MysqlType::Time
            }
        }
        impl diesel::sql_types::HasSqlType<Time> for diesel::mariadb::Mariadb
            {
            fn metadata(_: &mut ()) -> diesel::mariadb::MariadbType {
                diesel::mariadb::MariadbType::Time
            }
        }
        impl diesel::sql_types::HasSqlType<Time> for diesel::pg::Pg {
            fn metadata(_: &mut Self::MetadataLookup)
                -> diesel::pg::PgTypeMetadata {
                diesel::pg::PgTypeMetadata::new(1083, 1183)
            }
        }
    };SqlType)]
340#[diesel(postgres_type(oid = 1083, array_oid = 1183))]
341#[diesel(sqlite_type(name = "Text"))]
342#[diesel(mysql_type(name = "Time"))]
343#[diesel(mariadb_type(name = "Time"))]
344pub struct Time;
345
346#[allow(rustdoc::redundant_explicit_links)]
347/// The timestamp SQL type.
348///
349/// ### [`ToSql`](crate::serialize::ToSql) impls
350///
351/// - [`std::time::SystemTime`][SystemTime] (PG only)
352/// - [`chrono::NaiveDateTime`][NaiveDateTime] with `feature = "chrono"`
353/// - [`time::PrimitiveDateTime`] with `feature = "time"`
354/// - [`time::OffsetDateTime`] with `feature = "time"` (MySQL only)
355///
356/// ### [`FromSql`](crate::deserialize::FromSql) impls
357///
358/// - [`std::time::SystemTime`][SystemTime] (PG only)
359/// - [`chrono::NaiveDateTime`][NaiveDateTime] with `feature = "chrono"`
360/// - [`time::PrimitiveDateTime`] with `feature = "time"`
361/// - [`time::OffsetDateTime`] with `feature = "time"` (MySQL only)
362///
363/// [SystemTime]: std::time::SystemTime
364#[cfg_attr(
365    feature = "chrono",
366    doc = " [NaiveDateTime]: chrono::naive::NaiveDateTime"
367)]
368#[cfg_attr(
369    not(feature = "chrono"),
370    doc = " [NaiveDateTime]: https://docs.rs/chrono/*/chrono/naive/struct.NaiveDateTime.html"
371)]
372#[cfg_attr(
373    feature = "time",
374    doc = " [`time::PrimitiveDateTime`]: time::PrimitiveDateTime"
375)]
376#[cfg_attr(
377    not(feature = "time"),
378    doc = " [`time::PrimitiveDateTime`]: https://docs.rs/time/0.3.9/time/struct.PrimitiveDateTime.html"
379)]
380#[cfg_attr(
381    feature = "time",
382    doc = " [`time::OffsetDateTime`]: time::OffsetDateTime"
383)]
384#[cfg_attr(
385    not(feature = "time"),
386    doc = " [`time::OffsetDateTime`]: https://docs.rs/time/0.3.9/time/struct.OffsetDateTime.html"
387)]
388/// [Timespec]: /time/struct.Timespec.html
389#[derive(#[automatically_derived]
#[allow(rustdoc::redundant_explicit_links)]
impl ::core::fmt::Debug for Timestamp {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f, "Timestamp")
    }
}Debug, #[automatically_derived]
#[doc(hidden)]
#[allow(rustdoc::redundant_explicit_links)]
unsafe impl ::core::clone::TrivialClone for Timestamp { }
#[automatically_derived]
#[allow(rustdoc::redundant_explicit_links)]
impl ::core::clone::Clone for Timestamp {
    #[inline]
    fn clone(&self) -> Timestamp { *self }
}Clone, #[automatically_derived]
#[allow(rustdoc::redundant_explicit_links)]
impl ::core::marker::Copy for Timestamp { }Copy, #[automatically_derived]
#[allow(rustdoc::redundant_explicit_links)]
impl ::core::default::Default for Timestamp {
    #[inline]
    fn default() -> Timestamp { Timestamp }
}Default, const _: () =
    {
        use diesel;
        #[allow(non_camel_case_types)]
        impl diesel::query_builder::QueryId for Timestamp {
            type QueryId = Timestamp<>;
            const HAS_STATIC_QUERY_ID: bool = true;
            const IS_WINDOW_FUNCTION: bool = false;
        }
    };QueryId, const _: () =
    {
        use diesel;
        impl diesel::sql_types::SqlType for Timestamp {
            type IsNull = diesel::sql_types::is_nullable::NotNull;
            const IS_ARRAY: bool = false;
        }
        impl diesel::sql_types::SingleValue for Timestamp {}
        impl diesel::sql_types::HasSqlType<Timestamp> for
            diesel::sqlite::Sqlite {
            fn metadata(_: &mut ()) -> diesel::sqlite::SqliteType {
                diesel::sqlite::SqliteType::Text
            }
        }
        impl diesel::sql_types::HasSqlType<Timestamp> for diesel::mysql::Mysql
            {
            fn metadata(_: &mut ()) -> diesel::mysql::MysqlType {
                diesel::mysql::MysqlType::Timestamp
            }
        }
        impl diesel::sql_types::HasSqlType<Timestamp> for
            diesel::mariadb::Mariadb {
            fn metadata(_: &mut ()) -> diesel::mariadb::MariadbType {
                diesel::mariadb::MariadbType::Timestamp
            }
        }
        impl diesel::sql_types::HasSqlType<Timestamp> for diesel::pg::Pg {
            fn metadata(_: &mut Self::MetadataLookup)
                -> diesel::pg::PgTypeMetadata {
                diesel::pg::PgTypeMetadata::new(1114, 1115)
            }
        }
    };SqlType)]
390#[diesel(postgres_type(oid = 1114, array_oid = 1115))]
391#[diesel(sqlite_type(name = "Text"))]
392#[diesel(mysql_type(name = "Timestamp"))]
393#[diesel(mariadb_type(name = "Timestamp"))]
394pub struct Timestamp;
395
396/// The JSON SQL type.  This type can only be used with `feature =
397/// "serde_json"`
398///
399/// For postgresql you should normally prefer [`Jsonb`](struct.Jsonb.html) instead,
400/// for the reasons discussed there.
401///
402/// ### Float round trip
403///
404/// Without `serde_json`'s `float_roundtrip` feature, a written `f64` may read
405/// back as the neighbouring double. Cargo features are additive, so a
406/// downstream crate can enable it.
407///
408/// ### [`ToSql`] impls
409///
410/// - [`serde_json::Value`]
411///
412/// ### [`FromSql`] impls
413///
414/// - [`serde_json::Value`]
415///
416/// [`ToSql`]: /serialize/trait.ToSql.html
417/// [`FromSql`]: /deserialize/trait.FromSql.html
418/// [`serde_json::Value`]: /../serde_json/value/enum.Value.html
419#[derive(#[automatically_derived]
impl ::core::fmt::Debug for Json {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f, "Json")
    }
}Debug, #[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for Json { }
#[automatically_derived]
impl ::core::clone::Clone for Json {
    #[inline]
    fn clone(&self) -> Json { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for Json { }Copy, #[automatically_derived]
impl ::core::default::Default for Json {
    #[inline]
    fn default() -> Json { Json }
}Default, const _: () =
    {
        use diesel;
        #[allow(non_camel_case_types)]
        impl diesel::query_builder::QueryId for Json {
            type QueryId = Json<>;
            const HAS_STATIC_QUERY_ID: bool = true;
            const IS_WINDOW_FUNCTION: bool = false;
        }
    };QueryId, const _: () =
    {
        use diesel;
        impl diesel::sql_types::SqlType for Json {
            type IsNull = diesel::sql_types::is_nullable::NotNull;
            const IS_ARRAY: bool = false;
        }
        impl diesel::sql_types::SingleValue for Json {}
        impl diesel::sql_types::HasSqlType<Json> for diesel::sqlite::Sqlite {
            fn metadata(_: &mut ()) -> diesel::sqlite::SqliteType {
                diesel::sqlite::SqliteType::Text
            }
        }
        impl diesel::sql_types::HasSqlType<Json> for diesel::mysql::Mysql {
            fn metadata(_: &mut ()) -> diesel::mysql::MysqlType {
                diesel::mysql::MysqlType::String
            }
        }
        impl diesel::sql_types::HasSqlType<Json> for diesel::mariadb::Mariadb
            {
            fn metadata(_: &mut ()) -> diesel::mariadb::MariadbType {
                diesel::mariadb::MariadbType::String
            }
        }
        impl diesel::sql_types::HasSqlType<Json> for diesel::pg::Pg {
            fn metadata(_: &mut Self::MetadataLookup)
                -> diesel::pg::PgTypeMetadata {
                diesel::pg::PgTypeMetadata::new(114, 199)
            }
        }
    };SqlType)]
420#[diesel(postgres_type(oid = 114, array_oid = 199))]
421#[diesel(mysql_type(name = "String"))]
422#[diesel(mariadb_type(name = "String"))]
423#[diesel(sqlite_type(name = "Text"))]
424pub struct Json;
425
426/// The [`jsonb`] SQL type.  This type can only be used with `feature =
427/// "serde_json"`
428///
429/// In SQLite, `jsonb` brings mainly [performance improvements][sqlite-adv] over
430/// regular JSON:
431///
432/// > The advantage of JSONB in SQLite is that it is smaller and faster than
433/// > text JSON - potentially several times faster. There is space in the
434/// > on-disk JSONB format to add enhancements and future versions of SQLite
435/// > might include options to provide O(1) lookup of elements in JSONB, but no
436/// > such capability is currently available.
437///
438/// <div class="warning">
439/// In SQLite, JSONB is intended for internal use by SQLite only. Thus, future
440/// SQLite updates might break our JSONB implementation. And one might have to
441/// wait and then upgrade <code>diesel</code> for those changes to be  accounted
442/// for. If you do not want this, prefer the regular
443/// <a href="./struct.Json.html"><code>Json</code></a> type.
444/// </div>
445///
446/// In PostgreSQL, `jsonb` offers [several advantages][pg-adv] over regular JSON:
447///
448/// > There are two JSON data types: `json` and `jsonb`. They accept almost
449/// > identical sets of values as input. The major practical difference
450/// > is one of efficiency. The `json` data type stores an exact copy of
451/// > the input text, which processing functions must reparse on each
452/// > execution; while `jsonb` data is stored in a decomposed binary format
453/// > that makes it slightly slower to input due to added conversion
454/// > overhead, but significantly faster to process, since no reparsing
455/// > is needed. `jsonb` also supports indexing, which can be a significant
456/// > advantage.
457/// >
458/// > ...In general, most applications should prefer to store JSON data as
459/// > `jsonb`, unless there are quite specialized needs, such as legacy
460/// > assumptions about ordering of object keys.
461///
462/// [pg-adv]: https://www.postgresql.org/docs/current/static/datatype-json.html
463/// [sqlite-adv]: https://sqlite.org/draft/jsonb.html
464///
465/// ### Float round trip
466///
467/// Without `serde_json`'s `float_roundtrip` feature, a written `f64` may read
468/// back as the neighbouring double. Cargo features are additive, so a
469/// downstream crate can enable it.
470///
471/// ### [`ToSql`] impls
472///
473/// - [`serde_json::Value`]
474///
475/// ### [`FromSql`] impls
476///
477/// - [`serde_json::Value`]
478///
479/// [`ToSql`]: crate::serialize::ToSql
480/// [`FromSql`]: crate::deserialize::FromSql
481/// [`jsonb`]: https://www.postgresql.org/docs/current/datatype-json.html
482#[cfg_attr(
483    feature = "serde_json",
484    doc = "[`serde_json::Value`]: serde_json::value::Value"
485)]
486#[cfg_attr(
487    not(feature = "serde_json"),
488    doc = "[`serde_json::Value`]: https://docs.rs/serde_json/1.0.64/serde_json/value/enum.Value.html"
489)]
490///
491/// ## Examples
492///
493/// ```rust
494/// # #![allow(dead_code)]
495/// # include!("../doctest_setup.rs");
496/// #
497/// table! {
498///     contacts {
499///         id -> Integer,
500///         name -> Text,
501///         address -> Jsonb,
502///     }
503/// }
504///
505/// # #[cfg(all(
506/// #   feature = "serde_json",
507/// #   any(
508/// #       feature = "postgres_backend",
509/// #       feature = "returning_clauses_for_sqlite_3_35",
510/// #   )
511/// # ))]
512/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
513/// #     use diesel::insert_into;
514/// #     use self::contacts::dsl::*;
515/// #     let connection = &mut connection_no_data();
516/// # #[cfg(feature = "postgres_backend")]
517/// #     diesel::sql_query("CREATE TABLE contacts (
518/// #         id SERIAL PRIMARY KEY,
519/// #         name VARCHAR NOT NULL,
520/// #         address JSONB NOT NULL
521/// #     )").execute(connection)?;
522/// # #[cfg(feature = "__sqlite-shared")]
523/// #     diesel::sql_query("CREATE TABLE contacts (
524/// #         id INT PRIMARY KEY,
525/// #         name TEXT NOT NULL,
526/// #         address BLOB NOT NULL
527/// #     )").execute(connection)?;
528/// let santas_address: serde_json::Value = serde_json::from_str(
529///     r#"{
530///     "street": "Article Circle Expressway 1",
531///     "city": "North Pole",
532///     "postcode": "99705",
533///     "state": "Alaska"
534/// }"#,
535/// )?;
536/// let inserted_address = insert_into(contacts)
537///     .values((name.eq("Claus"), address.eq(&santas_address)))
538///     .returning(address)
539///     .get_result::<serde_json::Value>(connection)?;
540/// assert_eq!(santas_address, inserted_address);
541/// #     Ok(())
542/// # }
543/// # #[cfg(not(all(
544/// #   feature = "serde_json",
545/// #   any(
546/// #       feature = "postgres_backend",
547/// #       feature = "returning_clauses_for_sqlite_3_35",
548/// #   )
549/// # )))]
550/// # fn main() {}
551/// ```
552#[derive(#[automatically_derived]
impl ::core::fmt::Debug for Jsonb {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f, "Jsonb")
    }
}Debug, #[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for Jsonb { }
#[automatically_derived]
impl ::core::clone::Clone for Jsonb {
    #[inline]
    fn clone(&self) -> Jsonb { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for Jsonb { }Copy, #[automatically_derived]
impl ::core::default::Default for Jsonb {
    #[inline]
    fn default() -> Jsonb { Jsonb }
}Default, const _: () =
    {
        use diesel;
        #[allow(non_camel_case_types)]
        impl diesel::query_builder::QueryId for Jsonb {
            type QueryId = Jsonb<>;
            const HAS_STATIC_QUERY_ID: bool = true;
            const IS_WINDOW_FUNCTION: bool = false;
        }
    };QueryId, const _: () =
    {
        use diesel;
        impl diesel::sql_types::SqlType for Jsonb {
            type IsNull = diesel::sql_types::is_nullable::NotNull;
            const IS_ARRAY: bool = false;
        }
        impl diesel::sql_types::SingleValue for Jsonb {}
        impl diesel::sql_types::HasSqlType<Jsonb> for diesel::sqlite::Sqlite {
            fn metadata(_: &mut ()) -> diesel::sqlite::SqliteType {
                diesel::sqlite::SqliteType::Binary
            }
        }
        impl diesel::sql_types::HasSqlType<Jsonb> for diesel::pg::Pg {
            fn metadata(_: &mut Self::MetadataLookup)
                -> diesel::pg::PgTypeMetadata {
                diesel::pg::PgTypeMetadata::new(3802, 3807)
            }
        }
    };SqlType)]
553#[diesel(postgres_type(oid = 3802, array_oid = 3807))]
554#[diesel(sqlite_type(name = "Binary"))]
555pub struct Jsonb;
556
557/// The nullable SQL type.
558///
559/// This wraps another SQL type to indicate that it can be null.
560/// By default all values are assumed to be `NOT NULL`.
561///
562/// ### [`ToSql`](crate::serialize::ToSql) impls
563///
564/// - Any `T` which implements `ToSql<ST>`
565/// - `Option<T>` for any `T` which implements `ToSql<ST>`
566///
567/// ### [`FromSql`](crate::deserialize::FromSql) impls
568///
569/// - `Option<T>` for any `T` which implements `FromSql<ST>`
570#[derive(#[automatically_derived]
impl<ST: ::core::fmt::Debug> ::core::fmt::Debug for Nullable<ST> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Nullable",
            &&self.0)
    }
}Debug, #[automatically_derived]
impl<ST: ::core::clone::Clone> ::core::clone::Clone for Nullable<ST> {
    #[inline]
    fn clone(&self) -> Nullable<ST> {
        Nullable(::core::clone::Clone::clone(&self.0))
    }
}Clone, #[automatically_derived]
impl<ST: ::core::marker::Copy> ::core::marker::Copy for Nullable<ST> { }Copy, #[automatically_derived]
impl<ST: ::core::default::Default> ::core::default::Default for Nullable<ST> {
    #[inline]
    fn default() -> Nullable<ST> {
        Nullable(::core::default::Default::default())
    }
}Default)]
571pub struct Nullable<ST>(ST);
572
573impl<ST> SqlType for Nullable<ST>
574where
575    ST: SqlType,
576{
577    type IsNull = is_nullable::IsNullable;
578}
579
580#[doc(inline)]
581#[cfg(feature = "postgres_backend")]
582pub use crate::pg::sql_types::*;
583
584#[doc(inline)]
585#[cfg(any(feature = "mysql_backend", feature = "mariadb_backend"))]
586pub use crate::mysql_like::sql_types::{Datetime, Unsigned};
587
588#[doc(inline)]
589#[cfg(feature = "__sqlite-shared")]
590pub use crate::sqlite::sql_types::Timestamptz as TimestamptzSqlite;
591
592/// Indicates that a SQL type exists for a backend.
593///
594/// This trait can be derived using the [`SqlType` derive](derive@SqlType)
595///
596/// # Example
597///
598/// ```rust
599/// #[derive(diesel::sql_types::SqlType)]
600/// #[diesel(postgres_type(oid = 23, array_oid = 1007))]
601/// #[diesel(sqlite_type(name = "Integer"))]
602/// #[diesel(mysql_type(name = "Long"))]
603/// #[diesel(mariadb_type(name = "Long"))]
604/// pub struct Integer;
605/// ```
606pub trait HasSqlType<ST>: TypeMetadata {
607    /// Fetch the metadata for the given type
608    ///
609    /// This method may use `lookup` to do dynamic runtime lookup. Implementors
610    /// of this method should not do dynamic lookup unless absolutely necessary
611    fn metadata(lookup: &mut Self::MetadataLookup) -> Self::TypeMetadata;
612}
613
614/// Information about how a backend stores metadata about given SQL types
615pub trait TypeMetadata {
616    /// The actual type used to represent metadata.
617    ///
618    /// On PostgreSQL, this is the type's OID.
619    /// On MySQL and SQLite, this is an enum representing all storage classes
620    /// they support.
621    type TypeMetadata;
622    /// The type used for runtime lookup of metadata.
623    ///
624    /// For most backends, which don't support user defined types, this will
625    /// be `()`.
626    type MetadataLookup: ?Sized;
627}
628
629/// Converts a type which may or may not be nullable into its nullable
630/// representation.
631pub trait IntoNullable {
632    /// The nullable representation of this type.
633    ///
634    /// For all types except `Nullable`, this will be `Nullable<Self>`.
635    type Nullable;
636}
637
638impl<T> IntoNullable for T
639where
640    T: SqlType<IsNull = is_nullable::NotNull> + SingleValue,
641{
642    type Nullable = Nullable<T>;
643}
644
645impl<T> IntoNullable for Nullable<T>
646where
647    T: SqlType,
648{
649    type Nullable = Self;
650}
651
652/// Converts a type which may or may not be nullable into its not nullable
653/// representation.
654pub trait IntoNotNullable {
655    /// The not nullable representation of this type.
656    ///
657    /// For `Nullable<T>`, this will be `T` otherwise the type itself
658    type NotNullable;
659}
660
661impl<T> IntoNotNullable for T
662where
663    T: SqlType<IsNull = is_nullable::NotNull>,
664{
665    type NotNullable = T;
666}
667
668impl<T> IntoNotNullable for Nullable<T>
669where
670    T: SqlType,
671{
672    type NotNullable = T;
673}
674
675/// A marker trait indicating that a SQL type represents a single value, as
676/// opposed to a list of values.
677///
678/// This trait should generally be implemented for all SQL types with the
679/// exception of Rust tuples. If a column could have this as its type, this
680/// trait should be implemented.
681///
682/// # Deriving
683///
684/// This trait is automatically implemented by [`#[derive(SqlType)]`](derive@SqlType)
685pub trait SingleValue: SqlType {}
686
687impl<T: SqlType + SingleValue> SingleValue for Nullable<T> {}
688
689#[doc(inline)]
690pub use diesel_derives::DieselNumericOps;
691#[doc(inline)]
692pub use diesel_derives::SqlType;
693
694/// A marker trait for SQL types
695///
696/// # Deriving
697///
698/// This trait is automatically implemented by [`#[derive(SqlType)]`](derive@SqlType)
699/// which sets `IsNull` to [`is_nullable::NotNull`]
700pub trait SqlType: 'static {
701    /// Is this type nullable?
702    ///
703    /// This type should always be one of the structs in the ['is_nullable`]
704    /// module. See the documentation of those structs for more details.
705    ///
706    /// ['is_nullable`]: is_nullable
707    type IsNull: OneIsNullable<is_nullable::IsNullable> + OneIsNullable<is_nullable::NotNull>;
708
709    #[doc(hidden)]
710    const IS_ARRAY: bool = false;
711}
712
713/// A marker trait for SQL types representing database side enums
714///
715/// This trait describes how an enum should be mapped to the underlying database storage type
716/// by specifying one of a set of different strategies.
717///
718/// The generic constant `HAS_EXPLICIT_DISCRIMINANT` can be used to enforce that for a given mapping
719/// the user needs to provide explicit discriminant values. The [`#[derive(Enum)]`](crate::types::Enum) macro
720/// will pass the true only if this is the case.
721///
722/// The generic type `DB` represents the database backend for which this mapping is valid
723///
724/// # Deriving
725///
726/// This trait can be automatically derived by using [`#[derive(SqlType)]`](derive@SqlType)
727/// with the `#[diesel(enum_type)]` attribute
728#[doc = " A marker trait for SQL types representing database side enums"]
#[doc = ""]
#[doc =
" This trait describes how an enum should be mapped to the underlying database storage type"]
#[doc = " by specifying one of a set of different strategies."]
#[doc = ""]
#[doc =
" The generic constant `HAS_EXPLICIT_DISCRIMINANT` can be used to enforce that for a given mapping"]
#[doc =
" the user needs to provide explicit discriminant values. The [`#[derive(Enum)]`](crate::types::Enum) macro"]
#[doc = " will pass the true only if this is the case."]
#[doc = ""]
#[doc =
" The generic type `DB` represents the database backend for which this mapping is valid"]
#[doc = ""]
#[doc = " # Deriving"]
#[doc = ""]
#[doc =
" This trait can be automatically derived by using [`#[derive(SqlType)]`](derive@SqlType)"]
#[doc = " with the `#[diesel(enum_type)]` attribute"]
pub trait EnumSqlType<const HAS_EXPLICIT_DISCRIMINANT : bool,
    DB: Backend>: SqlType {
    /// The mapping strategy used by this type
    ///
    /// This mainly exists to share the logic between different SQL types
    type Strategy: crate::types::enum_::EnumMapping<DB>;
}#[diesel_derives::__diesel_public_if(
729    feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes"
730)]
731// TODO: it seems like `#[diagnostic::on_unimplemented]` doesn't work here
732pub trait EnumSqlType<const HAS_EXPLICIT_DISCRIMINANT: bool, DB: Backend>: SqlType {
733    /// The mapping strategy used by this type
734    ///
735    /// This mainly exists to share the logic between different SQL types
736    type Strategy: crate::types::enum_::EnumMapping<DB>;
737}
738
739/// Is one value of `IsNull` nullable?
740///
741/// You should never implement this trait.
742pub trait OneIsNullable<Other> {
743    /// See the trait documentation
744    type Out: OneIsNullable<is_nullable::IsNullable> + OneIsNullable<is_nullable::NotNull>;
745}
746
747/// Are both values of `IsNull` are nullable?
748pub trait AllAreNullable<Other> {
749    /// See the trait documentation
750    type Out: AllAreNullable<is_nullable::NotNull> + AllAreNullable<is_nullable::IsNullable>;
751}
752
753/// A type level constructor for maybe nullable types
754///
755/// Constructs either `Nullable<O>` (for `Self` == `is_nullable::IsNullable`)
756/// or `O` (for `Self` == `is_nullable::NotNull`)
757pub trait MaybeNullableType<O> {
758    /// See the trait documentation
759    type Out: SqlType + TypedExpressionType;
760}
761
762/// Possible values for `SqlType::IsNullable`
763pub mod is_nullable {
764    use super::*;
765
766    /// No, this type cannot be null as it is marked as `NOT NULL` at database level
767    ///
768    /// This should be chosen for basically all manual impls of `SqlType`
769    /// beside implementing your own `Nullable<>` wrapper type
770    #[derive(#[automatically_derived]
impl ::core::fmt::Debug for NotNull {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f, "NotNull")
    }
}Debug, #[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for NotNull { }
#[automatically_derived]
impl ::core::clone::Clone for NotNull {
    #[inline]
    fn clone(&self) -> NotNull { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for NotNull { }Copy)]
771    pub struct NotNull;
772
773    /// Yes, this type can be null
774    ///
775    /// The only diesel provided `SqlType` that uses this value is [`Nullable<T>`]
776    ///
777    /// [`Nullable<T>`]: Nullable
778    #[derive(#[automatically_derived]
impl ::core::fmt::Debug for IsNullable {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f, "IsNullable")
    }
}Debug, #[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for IsNullable { }
#[automatically_derived]
impl ::core::clone::Clone for IsNullable {
    #[inline]
    fn clone(&self) -> IsNullable { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for IsNullable { }Copy)]
779    pub struct IsNullable;
780
781    impl OneIsNullable<NotNull> for NotNull {
782        type Out = NotNull;
783    }
784
785    impl OneIsNullable<IsNullable> for NotNull {
786        type Out = IsNullable;
787    }
788
789    impl OneIsNullable<NotNull> for IsNullable {
790        type Out = IsNullable;
791    }
792
793    impl OneIsNullable<IsNullable> for IsNullable {
794        type Out = IsNullable;
795    }
796
797    impl AllAreNullable<NotNull> for NotNull {
798        type Out = NotNull;
799    }
800
801    impl AllAreNullable<IsNullable> for NotNull {
802        type Out = NotNull;
803    }
804
805    impl AllAreNullable<NotNull> for IsNullable {
806        type Out = NotNull;
807    }
808
809    impl AllAreNullable<IsNullable> for IsNullable {
810        type Out = IsNullable;
811    }
812
813    impl<O> MaybeNullableType<O> for NotNull
814    where
815        O: SqlType + TypedExpressionType,
816    {
817        type Out = O;
818    }
819
820    impl<O> MaybeNullableType<O> for IsNullable
821    where
822        O: SqlType,
823        Nullable<O>: TypedExpressionType,
824    {
825        type Out = Nullable<O>;
826    }
827
828    /// Represents the output type of [`MaybeNullableType`]
829    pub type MaybeNullable<N, T> = <N as MaybeNullableType<T>>::Out;
830
831    /// Represents the output type of [`OneIsNullable`]
832    pub type OneNullable<T1, T2> = <T1 as OneIsNullable<T2>>::Out;
833
834    /// Represents the output type of [`OneIsNullable`]
835    /// for two given SQL types
836    pub type IsOneNullable<S1, S2> = OneNullable<IsSqlTypeNullable<S1>, IsSqlTypeNullable<S2>>;
837
838    /// Represents the output type of [`AllAreNullable`]
839    /// for two given SQL types
840    pub type AreAllNullable<S1, S2> =
841        <IsSqlTypeNullable<S1> as AllAreNullable<IsSqlTypeNullable<S2>>>::Out;
842
843    /// Represents if the SQL type is nullable or not
844    pub type IsSqlTypeNullable<T> = <T as SqlType>::IsNull;
845}
846
847/// A marker trait for accepting expressions of the type `Bool` and
848/// `Nullable<Bool>` in the same place
849#[diagnostic::on_unimplemented(
850    message = "`{Self}` is neither `diesel::sql_types::Bool` nor `diesel::sql_types::Nullable<Bool>`",
851    note = "try to provide an expression that produces one of the expected sql types"
852)]
853pub trait BoolOrNullableBool {}
854
855impl BoolOrNullableBool for Bool {}
856impl BoolOrNullableBool for Nullable<Bool> {}
857
858#[doc(inline)]
859pub use crate::expression::expression_types::Untyped;
860
861pub(crate) mod helper {
862    use super::{MaybeNullableType, OneIsNullable, SingleValue};
863
864    pub trait CombinedNullableValue<O, Out>: SingleValue {
865        type Out: SingleValue;
866    }
867
868    impl<T, O, Out> CombinedNullableValue<O, Out> for T
869    where
870        T: SingleValue,
871        O: SingleValue,
872        T::IsNull: OneIsNullable<O::IsNull>,
873        <T::IsNull as OneIsNullable<O::IsNull>>::Out: MaybeNullableType<Out>,
874        <<T::IsNull as OneIsNullable<O::IsNull>>::Out as MaybeNullableType<Out>>::Out: SingleValue,
875    {
876        type Out = <<T::IsNull as OneIsNullable<O::IsNull>>::Out as MaybeNullableType<Out>>::Out;
877    }
878}