Skip to main content

diesel/pg/types/
mod.rs

1//! PostgreSQL specific types
2
3#[doc(hidden)]
4pub(in crate::pg) mod array;
5#[doc(hidden)]
6pub(in crate::pg) mod date_and_time;
7#[doc(hidden)]
8pub(in crate::pg) mod floats;
9mod integers;
10#[cfg(feature = "ipnet-address")]
11mod ipnet_address;
12#[cfg(feature = "serde_json")]
13mod json;
14mod json_function_enum;
15mod mac_addr;
16mod mac_addr_8;
17#[doc(hidden)]
18pub(in crate::pg) mod money;
19mod multirange;
20#[cfg(feature = "network-address")]
21mod network_address;
22mod numeric;
23pub(in crate::pg) mod pg_lsn;
24mod primitives;
25mod ranges;
26mod record;
27#[cfg(feature = "uuid")]
28mod uuid;
29
30/// PostgreSQL specific SQL types
31///
32/// Note: All types in this module can be accessed through `diesel::sql_types`
33pub mod sql_types {
34    use crate::query_builder::QueryId;
35    use crate::sql_types::SqlType;
36
37    /// The [`OID`] SQL type. This is a PostgreSQL specific type.
38    ///
39    /// ### [`ToSql`] impls
40    ///
41    /// - [`u32`]
42    ///
43    /// ### [`FromSql`] impls
44    ///
45    /// - [`u32`]
46    ///
47    /// [`ToSql`]: crate::serialize::ToSql
48    /// [`FromSql`]: crate::deserialize::FromSql
49    /// [`u32`]: https://doc.rust-lang.org/nightly/std/primitive.u32.html
50    /// [`OID`]: https://www.postgresql.org/docs/current/datatype-oid.html
51    #[cfg(feature = "postgres_backend")]
52    #[derive(#[automatically_derived]
impl ::core::fmt::Debug for Oid {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f, "Oid")
    }
}Debug, #[automatically_derived]
impl ::core::clone::Clone for Oid {
    #[inline]
    fn clone(&self) -> Oid { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for Oid { }Copy, #[automatically_derived]
impl ::core::default::Default for Oid {
    #[inline]
    fn default() -> Oid { Oid {} }
}Default, const _: () =
    {
        use diesel;
        #[allow(non_camel_case_types)]
        impl diesel::query_builder::QueryId for Oid {
            type QueryId = Oid<>;
            const HAS_STATIC_QUERY_ID: bool = true;
            const IS_WINDOW_FUNCTION: bool = false;
        }
    };QueryId, const _: () =
    {
        use diesel;
        impl diesel::sql_types::SqlType for Oid {
            type IsNull = diesel::sql_types::is_nullable::NotNull;
            const IS_ARRAY: bool = false;
        }
        impl diesel::sql_types::SingleValue for Oid {}
        impl diesel::sql_types::HasSqlType<Oid> for diesel::pg::Pg {
            fn metadata(_: &mut Self::MetadataLookup)
                -> diesel::pg::PgTypeMetadata {
                diesel::pg::PgTypeMetadata::new(26, 1028)
            }
        }
    };SqlType)]
53    #[diesel(postgres_type(oid = 26, array_oid = 1028))]
54    pub struct Oid;
55
56    /// The ["timestamp with time zone" SQL type][tz], which PostgreSQL abbreviates
57    /// to `timestamptz`.
58    ///
59    /// ### [`ToSql`] impls
60    ///
61    /// - [`PgTimestamp`]
62    /// - [`chrono::NaiveDateTime`] with `feature = "chrono"`
63    /// - [`chrono::DateTime`] with `feature = "chrono"`
64    /// - [`time::PrimitiveDateTime`] with `feature = "time"`
65    /// - [`time::OffsetDateTime`] with `feature = "time"`
66    ///
67    /// ### [`FromSql`] impls
68    ///
69    /// - [`PgTimestamp`]
70    /// - [`chrono::NaiveDateTime`] with `feature = "chrono"`
71    /// - [`chrono::DateTime`] with `feature = "chrono"`
72    /// - [`time::PrimitiveDateTime`] with `feature = "time"`
73    /// - [`time::OffsetDateTime`] with `feature = "time"`
74    ///
75    /// [`ToSql`]: crate::serialize::ToSql
76    /// [`FromSql`]: crate::deserialize::FromSql
77    /// [`PgTimestamp`]: super::super::data_types::PgTimestamp
78    /// [tz]: https://www.postgresql.org/docs/current/datatype-datetime.html
79    #[cfg_attr(
80        feature = "chrono",
81        doc = " [`chrono::NaiveDateTime`]: chrono::naive::NaiveDateTime"
82    )]
83    #[cfg_attr(
84        not(feature = "chrono"),
85        doc = " [`chrono::NaiveDateTime`]: https://docs.rs/chrono/0.4.19/chrono/naive/struct.NaiveDateTime.html"
86    )]
87    #[cfg_attr(feature = "chrono", doc = " [`chrono::DateTime`]: chrono::DateTime")]
88    #[cfg_attr(
89        not(feature = "chrono"),
90        doc = " [`chrono::DateTime`]: https://docs.rs/chrono/0.4.19/chrono/struct.DateTime.html"
91    )]
92    #[cfg_attr(
93        feature = "time",
94        doc = " [`time::PrimitiveDateTime`]: time::PrimitiveDateTime"
95    )]
96    #[cfg_attr(
97        not(feature = "time"),
98        doc = " [`time::PrimitiveDateTime`]: https://docs.rs/time/0.3.9/time/struct.PrimitiveDateTime.html"
99    )]
100    #[cfg_attr(
101        feature = "time",
102        doc = " [`time::OffsetDateTime`]: time::OffsetDateTime"
103    )]
104    #[cfg_attr(
105        not(feature = "time"),
106        doc = " [`time::OffsetDateTime`]: https://docs.rs/time/0.3.9/time/struct.OffsetDateTime.html"
107    )]
108    #[cfg(feature = "postgres_backend")]
109    #[derive(#[automatically_derived]
impl ::core::fmt::Debug for Timestamptz {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f, "Timestamptz")
    }
}Debug, #[automatically_derived]
impl ::core::clone::Clone for Timestamptz {
    #[inline]
    fn clone(&self) -> Timestamptz { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for Timestamptz { }Copy, #[automatically_derived]
impl ::core::default::Default for Timestamptz {
    #[inline]
    fn default() -> Timestamptz { Timestamptz {} }
}Default, const _: () =
    {
        use diesel;
        #[allow(non_camel_case_types)]
        impl diesel::query_builder::QueryId for Timestamptz {
            type QueryId = Timestamptz<>;
            const HAS_STATIC_QUERY_ID: bool = true;
            const IS_WINDOW_FUNCTION: bool = false;
        }
    };QueryId, const _: () =
    {
        use diesel;
        impl diesel::sql_types::SqlType for Timestamptz {
            type IsNull = diesel::sql_types::is_nullable::NotNull;
            const IS_ARRAY: bool = false;
        }
        impl diesel::sql_types::SingleValue for Timestamptz {}
        impl diesel::sql_types::HasSqlType<Timestamptz> for diesel::pg::Pg {
            fn metadata(_: &mut Self::MetadataLookup)
                -> diesel::pg::PgTypeMetadata {
                diesel::pg::PgTypeMetadata::new(1184, 1185)
            }
        }
    };SqlType)]
110    #[diesel(postgres_type(oid = 1184, array_oid = 1185))]
111    pub struct Timestamptz;
112
113    /// The [`Array`] SQL type.
114    ///
115    /// This wraps another type to represent a SQL array of that type.
116    /// Multidimensional arrays are not supported.
117    ///
118    /// ### [`ToSql`] impls
119    ///
120    /// - [`Vec<T>`][Vec] for any `T` which implements `ToSql<ST>`
121    /// - [`&[T]`][slice] for any `T` which implements `ToSql<ST>`
122    ///
123    /// ### [`FromSql`] impls
124    ///
125    /// - [`Vec<T>`][Vec] for any `T` which implements `ToSql<ST>`
126    ///
127    /// [`ToSql`]: crate::serialize::ToSql
128    /// [`FromSql`]: crate::deserialize::FromSql
129    /// [Vec]: std::vec::Vec
130    /// [slice]: https://doc.rust-lang.org/nightly/std/primitive.slice.html
131    /// [`Array`]: https://www.postgresql.org/docs/current/arrays.html
132    #[derive(#[automatically_derived]
impl<ST: ::core::fmt::Debug + 'static> ::core::fmt::Debug for Array<ST> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Array",
            &&self.0)
    }
}Debug, #[automatically_derived]
impl<ST: ::core::clone::Clone + 'static> ::core::clone::Clone for Array<ST> {
    #[inline]
    fn clone(&self) -> Array<ST> {
        Array(::core::clone::Clone::clone(&self.0))
    }
}Clone, #[automatically_derived]
impl<ST: ::core::marker::Copy + 'static> ::core::marker::Copy for Array<ST> {
}Copy, #[automatically_derived]
impl<ST: ::core::default::Default + 'static> ::core::default::Default for
    Array<ST> {
    #[inline]
    fn default() -> Array<ST> { Array(::core::default::Default::default()) }
}Default, const _: () =
    {
        use diesel;
        #[allow(non_camel_case_types)]
        impl<ST: 'static + diesel::query_builder::QueryId>
            diesel::query_builder::QueryId for Array<ST> {
            type QueryId =
                Array<<ST as diesel::query_builder::QueryId>::QueryId>;
            const HAS_STATIC_QUERY_ID: bool =
                <ST as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                    true;
            const IS_WINDOW_FUNCTION: bool =
                <ST as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                    false;
        }
    };QueryId, const _: () =
    {
        use diesel;
        impl<ST: 'static> diesel::sql_types::SqlType for Array<ST> {
            type IsNull = diesel::sql_types::is_nullable::NotNull;
            const IS_ARRAY: bool = true;
        }
        impl<ST: 'static> diesel::sql_types::SingleValue for Array<ST> {}
    };SqlType)]
133    #[cfg(feature = "postgres_backend")]
134    pub struct Array<ST: 'static>(ST);
135
136    /// The [`Range`] SQL type.
137    ///
138    /// This wraps another type to represent a SQL range of that type.
139    ///
140    /// ### [`ToSql`] impls
141    ///
142    /// - [`(Bound<T>, Bound<T>)`][bound] for any `T` which implements `ToSql<ST>`.
143    /// - [`Range<T>`][std::range] (aka `start..end`) for any `T` which implements `ToSql<ST>`.
144    /// - [`RangeInclusive<T>`] (aka `start..=end`) for any `T` which implements `ToSql<ST>`.
145    /// - [`RangeFrom<T>`] (aka `start..`) for any `T` which implements `ToSql<ST>`.
146    /// - [`RangeTo<T>`] (aka `..end`) for any `T` which implements `ToSql<ST>`.
147    /// - [`RangeToInclusive<T>`] (aka `..=end`) for any `T` which implements `ToSql<ST>`.
148    ///
149    /// ### [`FromSql`] impls
150    ///
151    /// - [`(Bound<T>, Bound<T>)`][bound] for any `T` which implements `FromSql<ST>`.
152    ///
153    /// [`ToSql`]: crate::serialize::ToSql
154    /// [`FromSql`]: crate::deserialize::FromSql
155    /// [bound]: std::collections::Bound
156    /// [std::range]: std::ops::Range
157    /// [`RangeInclusive<T>`]: std::ops::RangeInclusive
158    /// [`RangeFrom<T>`]: std::ops::RangeFrom
159    /// [`RangeTo<T>`]: std::ops::RangeTo
160    /// [`RangeToInclusive<T>`]: std::ops::RangeToInclusive
161    /// [`Range`]: https://www.postgresql.org/docs/current/rangetypes.html
162    #[derive(#[automatically_derived]
impl<ST: ::core::fmt::Debug + 'static> ::core::fmt::Debug for Range<ST> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Range",
            &&self.0)
    }
}Debug, #[automatically_derived]
impl<ST: ::core::clone::Clone + 'static> ::core::clone::Clone for Range<ST> {
    #[inline]
    fn clone(&self) -> Range<ST> {
        Range(::core::clone::Clone::clone(&self.0))
    }
}Clone, #[automatically_derived]
impl<ST: ::core::marker::Copy + 'static> ::core::marker::Copy for Range<ST> {
}Copy, #[automatically_derived]
impl<ST: ::core::default::Default + 'static> ::core::default::Default for
    Range<ST> {
    #[inline]
    fn default() -> Range<ST> { Range(::core::default::Default::default()) }
}Default, const _: () =
    {
        use diesel;
        #[allow(non_camel_case_types)]
        impl<ST: 'static + diesel::query_builder::QueryId>
            diesel::query_builder::QueryId for Range<ST> {
            type QueryId =
                Range<<ST as diesel::query_builder::QueryId>::QueryId>;
            const HAS_STATIC_QUERY_ID: bool =
                <ST as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                    true;
            const IS_WINDOW_FUNCTION: bool =
                <ST as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                    false;
        }
    };QueryId, const _: () =
    {
        use diesel;
        impl<ST: 'static> diesel::sql_types::SqlType for Range<ST> {
            type IsNull = diesel::sql_types::is_nullable::NotNull;
            const IS_ARRAY: bool = false;
        }
        impl<ST: 'static> diesel::sql_types::SingleValue for Range<ST> {}
    };SqlType)]
163    #[cfg(feature = "postgres_backend")]
164    pub struct Range<ST: 'static>(ST);
165
166    #[doc(hidden)]
167    pub type Int4range = Range<crate::sql_types::Int4>;
168    #[doc(hidden)]
169    pub type Int8range = Range<crate::sql_types::Int8>;
170    #[doc(hidden)]
171    pub type Daterange = Range<crate::sql_types::Date>;
172    #[doc(hidden)]
173    pub type Numrange = Range<crate::sql_types::Numeric>;
174    #[doc(hidden)]
175    pub type Tsrange = Range<crate::sql_types::Timestamp>;
176    #[doc(hidden)]
177    pub type Tstzrange = Range<crate::sql_types::Timestamptz>;
178
179    /// The [`Multirange`] SQL type.
180    ///
181    /// This wraps another type to represent a SQL range of that type.
182    ///
183    /// ### [`ToSql`] impls
184    ///
185    /// - [`Vec<T>`][Vec] for any `T` which `Range<T>` implements `ToSql<ST>`
186    /// - [`&[T]`][slice] for any `T` which `Range<T>` implements `ToSql<ST>`
187    ///
188    /// ### [`FromSql`] impls
189    ///
190    /// - [`Vec<T>`][Vec] for any `T` which implements `ToSql<Range<ST>>`
191    ///
192    /// [`ToSql`]: crate::serialize::ToSql
193    /// [`FromSql`]: crate::deserialize::FromSql
194    /// [Vec]: std::vec::Vec
195    /// [slice]: https://doc.rust-lang.org/nightly/std/primitive.slice.html
196    /// [`Multirange`]: https://www.postgresql.org/docs/current/rangetypes.html
197    #[derive(#[automatically_derived]
impl<ST: ::core::fmt::Debug + 'static> ::core::fmt::Debug for Multirange<ST> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Multirange",
            &&self.0)
    }
}Debug, #[automatically_derived]
impl<ST: ::core::clone::Clone + 'static> ::core::clone::Clone for
    Multirange<ST> {
    #[inline]
    fn clone(&self) -> Multirange<ST> {
        Multirange(::core::clone::Clone::clone(&self.0))
    }
}Clone, #[automatically_derived]
impl<ST: ::core::marker::Copy + 'static> ::core::marker::Copy for
    Multirange<ST> {
}Copy, #[automatically_derived]
impl<ST: ::core::default::Default + 'static> ::core::default::Default for
    Multirange<ST> {
    #[inline]
    fn default() -> Multirange<ST> {
        Multirange(::core::default::Default::default())
    }
}Default, const _: () =
    {
        use diesel;
        #[allow(non_camel_case_types)]
        impl<ST: 'static + diesel::query_builder::QueryId>
            diesel::query_builder::QueryId for Multirange<ST> {
            type QueryId =
                Multirange<<ST as diesel::query_builder::QueryId>::QueryId>;
            const HAS_STATIC_QUERY_ID: bool =
                <ST as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                    true;
            const IS_WINDOW_FUNCTION: bool =
                <ST as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                    false;
        }
    };QueryId, const _: () =
    {
        use diesel;
        impl<ST: 'static> diesel::sql_types::SqlType for Multirange<ST> {
            type IsNull = diesel::sql_types::is_nullable::NotNull;
            const IS_ARRAY: bool = false;
        }
        impl<ST: 'static> diesel::sql_types::SingleValue for Multirange<ST> {}
    };SqlType)]
198    #[cfg(feature = "postgres_backend")]
199    pub struct Multirange<ST: 'static>(ST);
200
201    #[doc(hidden)]
202    pub type Int4multirange = Multirange<crate::sql_types::Int4>;
203    #[doc(hidden)]
204    pub type Int8multirange = Multirange<crate::sql_types::Int8>;
205    #[doc(hidden)]
206    pub type Datemultirange = Multirange<crate::sql_types::Date>;
207    #[doc(hidden)]
208    pub type Nummultirange = Multirange<crate::sql_types::Numeric>;
209    #[doc(hidden)]
210    pub type Tsmultirange = Multirange<crate::sql_types::Timestamp>;
211    #[doc(hidden)]
212    pub type Tstzmultirange = Multirange<crate::sql_types::Timestamptz>;
213
214    /// This is a wrapper for [`NullValueTreatment`] to represent null_value_treatment for jsonb_seet_lax:
215    ///     'raise_exception' 'use_json_null' 'delete_key' 'return_target'
216    /// used in functions jsonb_set_lax
217    #[derive(#[automatically_derived]
impl ::core::fmt::Debug for NullValueTreatmentEnum {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f, "NullValueTreatmentEnum")
    }
}Debug, #[automatically_derived]
impl ::core::clone::Clone for NullValueTreatmentEnum {
    #[inline]
    fn clone(&self) -> NullValueTreatmentEnum { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for NullValueTreatmentEnum { }Copy, const _: () =
    {
        use diesel;
        #[allow(non_camel_case_types)]
        impl diesel::query_builder::QueryId for NullValueTreatmentEnum {
            type QueryId = NullValueTreatmentEnum<>;
            const HAS_STATIC_QUERY_ID: bool = true;
            const IS_WINDOW_FUNCTION: bool = false;
        }
    };QueryId, const _: () =
    {
        use diesel;
        impl diesel::sql_types::SqlType for NullValueTreatmentEnum {
            type IsNull = diesel::sql_types::is_nullable::NotNull;
            const IS_ARRAY: bool = false;
        }
        impl diesel::sql_types::SingleValue for NullValueTreatmentEnum {}
        impl diesel::sql_types::HasSqlType<NullValueTreatmentEnum> for
            diesel::pg::Pg {
            fn metadata(lookup: &mut Self::MetadataLookup)
                -> diesel::pg::PgTypeMetadata {
                use diesel::pg::PgMetadataLookup;
                lookup.lookup_type("text", None)
            }
        }
    };SqlType)]
218    #[cfg(feature = "postgres_backend")]
219    #[diesel(postgres_type(name = "text"))]
220    pub struct NullValueTreatmentEnum;
221
222    /// Represent null_value_treatment for jsonb_seet_lax:
223    ///     'raise_exception' 'use_json_null' 'delete_key' 'return_target'
224    /// used in functions jsonb_seet_lax.
225    #[derive(#[automatically_derived]
#[allow(clippy::enum_variant_names)]
impl ::core::fmt::Debug for NullValueTreatment {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                NullValueTreatment::RaiseException => "RaiseException",
                NullValueTreatment::UseJsonNull => "UseJsonNull",
                NullValueTreatment::DeleteKey => "DeleteKey",
                NullValueTreatment::ReturnTarget => "ReturnTarget",
            })
    }
}Debug, #[automatically_derived]
#[allow(clippy::enum_variant_names)]
impl ::core::clone::Clone for NullValueTreatment {
    #[inline]
    fn clone(&self) -> NullValueTreatment { *self }
}Clone, #[automatically_derived]
#[allow(clippy::enum_variant_names)]
impl ::core::marker::Copy for NullValueTreatment { }Copy, const _: () =
    {
        use diesel;
        impl<'__expr> diesel::expression::AsExpression<NullValueTreatmentEnum>
            for &'__expr NullValueTreatment {
            type Expression =
                diesel::internal::derives::as_expression::Bound<NullValueTreatmentEnum,
                Self>;
            fn as_expression(self)
                ->
                    <Self as
                    diesel::expression::AsExpression<NullValueTreatmentEnum>>::Expression {
                diesel::internal::derives::as_expression::Bound::new(self)
            }
        }
        #[diagnostic::do_not_recommend]
        impl<'__expr>
            diesel::expression::AsExpression<diesel::sql_types::Nullable<NullValueTreatmentEnum>>
            for &'__expr NullValueTreatment {
            type Expression =
                diesel::internal::derives::as_expression::Bound<diesel::sql_types::Nullable<NullValueTreatmentEnum>,
                Self>;
            fn as_expression(self)
                ->
                    <Self as
                    diesel::expression::AsExpression<diesel::sql_types::Nullable<NullValueTreatmentEnum>>>::Expression {
                diesel::internal::derives::as_expression::Bound::new(self)
            }
        }
        #[diagnostic::do_not_recommend]
        impl<'__expr, '__expr2>
            diesel::expression::AsExpression<NullValueTreatmentEnum> for
            &'__expr2 &'__expr NullValueTreatment {
            type Expression =
                diesel::internal::derives::as_expression::Bound<NullValueTreatmentEnum,
                Self>;
            fn as_expression(self)
                ->
                    <Self as
                    diesel::expression::AsExpression<NullValueTreatmentEnum>>::Expression {
                diesel::internal::derives::as_expression::Bound::new(self)
            }
        }
        #[diagnostic::do_not_recommend]
        impl<'__expr, '__expr2>
            diesel::expression::AsExpression<diesel::sql_types::Nullable<NullValueTreatmentEnum>>
            for &'__expr2 &'__expr NullValueTreatment {
            type Expression =
                diesel::internal::derives::as_expression::Bound<diesel::sql_types::Nullable<NullValueTreatmentEnum>,
                Self>;
            fn as_expression(self)
                ->
                    <Self as
                    diesel::expression::AsExpression<diesel::sql_types::Nullable<NullValueTreatmentEnum>>>::Expression {
                diesel::internal::derives::as_expression::Bound::new(self)
            }
        }
        impl<__DB>
            diesel::serialize::ToSql<diesel::sql_types::Nullable<NullValueTreatmentEnum>,
            __DB> for NullValueTreatment where __DB: diesel::backend::Backend,
            Self: diesel::serialize::ToSql<NullValueTreatmentEnum, __DB> {
            fn to_sql<'__b>(&'__b self,
                out: &mut diesel::serialize::Output<'__b, '_, __DB>)
                -> diesel::serialize::Result {
                diesel::serialize::ToSql::<NullValueTreatmentEnum,
                        __DB>::to_sql(self, out)
            }
        }
        impl diesel::expression::AsExpression<NullValueTreatmentEnum> for
            NullValueTreatment {
            type Expression =
                diesel::internal::derives::as_expression::Bound<NullValueTreatmentEnum,
                Self>;
            fn as_expression(self)
                ->
                    <Self as
                    diesel::expression::AsExpression<NullValueTreatmentEnum>>::Expression {
                diesel::internal::derives::as_expression::Bound::new(self)
            }
        }
        impl diesel::expression::AsExpression<diesel::sql_types::Nullable<NullValueTreatmentEnum>>
            for NullValueTreatment {
            type Expression =
                diesel::internal::derives::as_expression::Bound<diesel::sql_types::Nullable<NullValueTreatmentEnum>,
                Self>;
            fn as_expression(self)
                ->
                    <Self as
                    diesel::expression::AsExpression<diesel::sql_types::Nullable<NullValueTreatmentEnum>>>::Expression {
                diesel::internal::derives::as_expression::Bound::new(self)
            }
        }
    };diesel_derives::AsExpression)]
226    #[diesel(sql_type = NullValueTreatmentEnum)]
227    #[allow(clippy::enum_variant_names)]
228    pub enum NullValueTreatment {
229        /// postgres 'raise_exception'
230        RaiseException,
231        /// postgres 'use_json_null'
232        UseJsonNull,
233        /// postgres 'delete_key'
234        DeleteKey,
235        /// postgres 'return_target'
236        ReturnTarget,
237    }
238
239    /// This is a wrapper for [`RangeBound`] to represent range bounds: '[]', '(]', '[)', '()',
240    /// used in functions int4range, int8range, numrange, tsrange, tstzrange, daterange.
241    #[derive(#[automatically_derived]
impl ::core::fmt::Debug for RangeBoundEnum {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f, "RangeBoundEnum")
    }
}Debug, #[automatically_derived]
impl ::core::clone::Clone for RangeBoundEnum {
    #[inline]
    fn clone(&self) -> RangeBoundEnum { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for RangeBoundEnum { }Copy, const _: () =
    {
        use diesel;
        #[allow(non_camel_case_types)]
        impl diesel::query_builder::QueryId for RangeBoundEnum {
            type QueryId = RangeBoundEnum<>;
            const HAS_STATIC_QUERY_ID: bool = true;
            const IS_WINDOW_FUNCTION: bool = false;
        }
    };QueryId, const _: () =
    {
        use diesel;
        impl diesel::sql_types::SqlType for RangeBoundEnum {
            type IsNull = diesel::sql_types::is_nullable::NotNull;
            const IS_ARRAY: bool = false;
        }
        impl diesel::sql_types::SingleValue for RangeBoundEnum {}
        impl diesel::sql_types::HasSqlType<RangeBoundEnum> for diesel::pg::Pg
            {
            fn metadata(lookup: &mut Self::MetadataLookup)
                -> diesel::pg::PgTypeMetadata {
                use diesel::pg::PgMetadataLookup;
                lookup.lookup_type("text", None)
            }
        }
    };SqlType)]
242    #[cfg(feature = "postgres_backend")]
243    #[diesel(postgres_type(name = "text"))]
244    pub struct RangeBoundEnum;
245
246    /// Represent postgres range bounds: '[]', '(]', '[)', '()',
247    /// used in functions int4range, int8range, numrange, tsrange, tstzrange, daterange.
248    #[derive(#[automatically_derived]
#[allow(clippy::enum_variant_names)]
impl ::core::fmt::Debug for RangeBound {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                RangeBound::LowerBoundInclusiveUpperBoundInclusive =>
                    "LowerBoundInclusiveUpperBoundInclusive",
                RangeBound::LowerBoundInclusiveUpperBoundExclusive =>
                    "LowerBoundInclusiveUpperBoundExclusive",
                RangeBound::LowerBoundExclusiveUpperBoundInclusive =>
                    "LowerBoundExclusiveUpperBoundInclusive",
                RangeBound::LowerBoundExclusiveUpperBoundExclusive =>
                    "LowerBoundExclusiveUpperBoundExclusive",
            })
    }
}Debug, #[automatically_derived]
#[allow(clippy::enum_variant_names)]
impl ::core::clone::Clone for RangeBound {
    #[inline]
    fn clone(&self) -> RangeBound { *self }
}Clone, #[automatically_derived]
#[allow(clippy::enum_variant_names)]
impl ::core::marker::Copy for RangeBound { }Copy, const _: () =
    {
        use diesel;
        impl<'__expr> diesel::expression::AsExpression<RangeBoundEnum> for
            &'__expr RangeBound {
            type Expression =
                diesel::internal::derives::as_expression::Bound<RangeBoundEnum,
                Self>;
            fn as_expression(self)
                ->
                    <Self as
                    diesel::expression::AsExpression<RangeBoundEnum>>::Expression {
                diesel::internal::derives::as_expression::Bound::new(self)
            }
        }
        #[diagnostic::do_not_recommend]
        impl<'__expr>
            diesel::expression::AsExpression<diesel::sql_types::Nullable<RangeBoundEnum>>
            for &'__expr RangeBound {
            type Expression =
                diesel::internal::derives::as_expression::Bound<diesel::sql_types::Nullable<RangeBoundEnum>,
                Self>;
            fn as_expression(self)
                ->
                    <Self as
                    diesel::expression::AsExpression<diesel::sql_types::Nullable<RangeBoundEnum>>>::Expression {
                diesel::internal::derives::as_expression::Bound::new(self)
            }
        }
        #[diagnostic::do_not_recommend]
        impl<'__expr, '__expr2>
            diesel::expression::AsExpression<RangeBoundEnum> for
            &'__expr2 &'__expr RangeBound {
            type Expression =
                diesel::internal::derives::as_expression::Bound<RangeBoundEnum,
                Self>;
            fn as_expression(self)
                ->
                    <Self as
                    diesel::expression::AsExpression<RangeBoundEnum>>::Expression {
                diesel::internal::derives::as_expression::Bound::new(self)
            }
        }
        #[diagnostic::do_not_recommend]
        impl<'__expr, '__expr2>
            diesel::expression::AsExpression<diesel::sql_types::Nullable<RangeBoundEnum>>
            for &'__expr2 &'__expr RangeBound {
            type Expression =
                diesel::internal::derives::as_expression::Bound<diesel::sql_types::Nullable<RangeBoundEnum>,
                Self>;
            fn as_expression(self)
                ->
                    <Self as
                    diesel::expression::AsExpression<diesel::sql_types::Nullable<RangeBoundEnum>>>::Expression {
                diesel::internal::derives::as_expression::Bound::new(self)
            }
        }
        impl<__DB>
            diesel::serialize::ToSql<diesel::sql_types::Nullable<RangeBoundEnum>,
            __DB> for RangeBound where __DB: diesel::backend::Backend,
            Self: diesel::serialize::ToSql<RangeBoundEnum, __DB> {
            fn to_sql<'__b>(&'__b self,
                out: &mut diesel::serialize::Output<'__b, '_, __DB>)
                -> diesel::serialize::Result {
                diesel::serialize::ToSql::<RangeBoundEnum,
                        __DB>::to_sql(self, out)
            }
        }
        impl diesel::expression::AsExpression<RangeBoundEnum> for RangeBound {
            type Expression =
                diesel::internal::derives::as_expression::Bound<RangeBoundEnum,
                Self>;
            fn as_expression(self)
                ->
                    <Self as
                    diesel::expression::AsExpression<RangeBoundEnum>>::Expression {
                diesel::internal::derives::as_expression::Bound::new(self)
            }
        }
        impl diesel::expression::AsExpression<diesel::sql_types::Nullable<RangeBoundEnum>>
            for RangeBound {
            type Expression =
                diesel::internal::derives::as_expression::Bound<diesel::sql_types::Nullable<RangeBoundEnum>,
                Self>;
            fn as_expression(self)
                ->
                    <Self as
                    diesel::expression::AsExpression<diesel::sql_types::Nullable<RangeBoundEnum>>>::Expression {
                diesel::internal::derives::as_expression::Bound::new(self)
            }
        }
    };diesel_derives::AsExpression)]
249    #[diesel(sql_type = RangeBoundEnum)]
250    #[allow(clippy::enum_variant_names)]
251    pub enum RangeBound {
252        /// postgres '[]'
253        LowerBoundInclusiveUpperBoundInclusive,
254        /// postgres '[)'
255        LowerBoundInclusiveUpperBoundExclusive,
256        /// postgres '(]'
257        LowerBoundExclusiveUpperBoundInclusive,
258        /// postgres '()'
259        LowerBoundExclusiveUpperBoundExclusive,
260    }
261
262    /// The [`Record`] (a.k.a. tuple) SQL type.
263    ///
264    /// ### [`ToSql`] impls
265    ///
266    /// - Any tuple which can be serialized to each of the elements
267    ///   (note: There are major caveats, see the section below)
268    ///
269    /// ### [`FromSql`] impls
270    ///
271    /// - Any tuple which can be deserialized from each of the elements.
272    ///
273    /// [`ToSql`]: crate::serialize::ToSql
274    /// [`FromSql`]: crate::deserialize::FromSql
275    ///
276    /// ### Caveats about serialization
277    ///
278    /// Typically in the documentation for SQL types, we use "`FromSql` impls"
279    /// as a shorthand for "Rust types that you can use to represent this type".
280    /// For every other type, that means there is specifically an implementation
281    /// of the `FromSql` trait.
282    ///
283    /// However, PostgreSQL does not support transmission of anonymous record
284    /// types as bind parameters. It only supports transmission for named
285    /// composite types. For this reason, if you tried to do
286    /// `int_tuple_col.eq((1, 2))`, we will generate the SQL `int_tuple_col =
287    /// ($1, $2)` rather than `int_tuple_col = $1` as we would for anything
288    /// else.
289    ///
290    /// This should not be visible during normal usage. The only time this would
291    /// affect you is if you were attempting to use `sql_query` with tuples.
292    /// Your code would not compile in that case, as the `ToSql` trait itself is
293    /// not implemented.
294    ///
295    /// You can implement `ToSql` for named composite types. See [`WriteTuple`]
296    /// for details.
297    ///
298    /// [`WriteTuple`]: super::super::super::serialize::WriteTuple
299    /// [`Record`]: https://www.postgresql.org/docs/current/rowtypes.html
300    #[cfg(feature = "postgres_backend")]
301    #[derive(#[automatically_derived]
impl<ST: ::core::fmt::Debug + 'static> ::core::fmt::Debug for Record<ST> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Record",
            &&self.0)
    }
}Debug, #[automatically_derived]
impl<ST: ::core::clone::Clone + 'static> ::core::clone::Clone for Record<ST> {
    #[inline]
    fn clone(&self) -> Record<ST> {
        Record(::core::clone::Clone::clone(&self.0))
    }
}Clone, #[automatically_derived]
impl<ST: ::core::marker::Copy + 'static> ::core::marker::Copy for Record<ST> {
}Copy, #[automatically_derived]
impl<ST: ::core::default::Default + 'static> ::core::default::Default for
    Record<ST> {
    #[inline]
    fn default() -> Record<ST> { Record(::core::default::Default::default()) }
}Default, const _: () =
    {
        use diesel;
        #[allow(non_camel_case_types)]
        impl<ST: 'static + diesel::query_builder::QueryId>
            diesel::query_builder::QueryId for Record<ST> {
            type QueryId =
                Record<<ST as diesel::query_builder::QueryId>::QueryId>;
            const HAS_STATIC_QUERY_ID: bool =
                <ST as diesel::query_builder::QueryId>::HAS_STATIC_QUERY_ID &&
                    true;
            const IS_WINDOW_FUNCTION: bool =
                <ST as diesel::query_builder::QueryId>::IS_WINDOW_FUNCTION ||
                    false;
        }
    };QueryId, const _: () =
    {
        use diesel;
        impl<ST: 'static> diesel::sql_types::SqlType for Record<ST> {
            type IsNull = diesel::sql_types::is_nullable::NotNull;
            const IS_ARRAY: bool = false;
        }
        impl<ST: 'static> diesel::sql_types::SingleValue for Record<ST> {}
        impl<ST: 'static> diesel::sql_types::HasSqlType<Record<ST>> for
            diesel::pg::Pg {
            fn metadata(_: &mut Self::MetadataLookup)
                -> diesel::pg::PgTypeMetadata {
                diesel::pg::PgTypeMetadata::new(2249, 2287)
            }
        }
    };SqlType)]
302    #[diesel(postgres_type(oid = 2249, array_oid = 2287))]
303    pub struct Record<ST: 'static>(ST);
304
305    /// Alias for [`SmallInt`](crate::sql_types::SmallInt)
306    #[cfg(feature = "postgres_backend")]
307    pub type SmallSerial = crate::sql_types::SmallInt;
308
309    /// Alias for [`Integer`](crate::sql_types::Integer)
310    #[cfg(feature = "postgres_backend")]
311    pub type Serial = crate::sql_types::Integer;
312
313    /// Alias for [`BigInt`](crate::sql_types::BigInt)
314    #[cfg(feature = "postgres_backend")]
315    pub type BigSerial = crate::sql_types::BigInt;
316
317    /// The [`UUID`] SQL type. This type can only be used with `feature = "uuid"`
318    ///
319    /// ### [`ToSql`] impls
320    ///
321    /// - [`uuid::Uuid`][Uuid]
322    ///
323    /// ### [`FromSql`] impls
324    ///
325    /// - [`uuid::Uuid`][Uuid]
326    ///
327    /// [`ToSql`]: crate::serialize::ToSql
328    /// [`FromSql`]: crate::deserialize::FromSql
329    /// [Uuid]: https://docs.rs/uuid/*/uuid/struct.Uuid.html
330    /// [`UUID`]: https://www.postgresql.org/docs/current/datatype-uuid.html
331    #[cfg(feature = "postgres_backend")]
332    #[derive(#[automatically_derived]
impl ::core::fmt::Debug for Uuid {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f, "Uuid")
    }
}Debug, #[automatically_derived]
impl ::core::clone::Clone for Uuid {
    #[inline]
    fn clone(&self) -> Uuid { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for Uuid { }Copy, #[automatically_derived]
impl ::core::default::Default for Uuid {
    #[inline]
    fn default() -> Uuid { Uuid {} }
}Default, const _: () =
    {
        use diesel;
        #[allow(non_camel_case_types)]
        impl diesel::query_builder::QueryId for Uuid {
            type QueryId = Uuid<>;
            const HAS_STATIC_QUERY_ID: bool = true;
            const IS_WINDOW_FUNCTION: bool = false;
        }
    };QueryId, const _: () =
    {
        use diesel;
        impl diesel::sql_types::SqlType for Uuid {
            type IsNull = diesel::sql_types::is_nullable::NotNull;
            const IS_ARRAY: bool = false;
        }
        impl diesel::sql_types::SingleValue for Uuid {}
        impl diesel::sql_types::HasSqlType<Uuid> for diesel::pg::Pg {
            fn metadata(_: &mut Self::MetadataLookup)
                -> diesel::pg::PgTypeMetadata {
                diesel::pg::PgTypeMetadata::new(2950, 2951)
            }
        }
    };SqlType)]
333    #[diesel(postgres_type(oid = 2950, array_oid = 2951))]
334    pub struct Uuid;
335
336    /// Alias for `Binary`, to ensure `diesel print-schema` works
337    pub type Bytea = crate::sql_types::Binary;
338
339    #[doc(hidden)]
340    #[cfg(feature = "postgres_backend")]
341    #[derive(#[automatically_derived]
impl ::core::fmt::Debug for Bpchar {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f, "Bpchar")
    }
}Debug, #[automatically_derived]
impl ::core::clone::Clone for Bpchar {
    #[inline]
    fn clone(&self) -> Bpchar { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for Bpchar { }Copy, #[automatically_derived]
impl ::core::default::Default for Bpchar {
    #[inline]
    fn default() -> Bpchar { Bpchar {} }
}Default, const _: () =
    {
        use diesel;
        #[allow(non_camel_case_types)]
        impl diesel::query_builder::QueryId for Bpchar {
            type QueryId = Bpchar<>;
            const HAS_STATIC_QUERY_ID: bool = true;
            const IS_WINDOW_FUNCTION: bool = false;
        }
    };QueryId, const _: () =
    {
        use diesel;
        impl diesel::sql_types::SqlType for Bpchar {
            type IsNull = diesel::sql_types::is_nullable::NotNull;
            const IS_ARRAY: bool = false;
        }
        impl diesel::sql_types::SingleValue for Bpchar {}
        impl diesel::sql_types::HasSqlType<Bpchar> for diesel::pg::Pg {
            fn metadata(_: &mut Self::MetadataLookup)
                -> diesel::pg::PgTypeMetadata {
                diesel::pg::PgTypeMetadata::new(1042, 1014)
            }
        }
    };SqlType)]
342    #[diesel(postgres_type(oid = 1042, array_oid = 1014))]
343    pub struct Bpchar;
344
345    /// The PostgreSQL [Money](https://www.postgresql.org/docs/current/static/datatype-money.html) type.
346    ///
347    /// ### [`ToSql`] impls
348    ///
349    /// - [`Cents` (also aliased as `PgMoney`)][PgMoney]
350    ///
351    /// ### [`FromSql`] impls
352    ///
353    /// - [`Cents` (also aliased as `PgMoney`)][PgMoney]
354    ///
355    /// [`ToSql`]: crate::serialize::ToSql
356    /// [`FromSql`]: crate::deserialize::FromSql
357    /// [PgMoney]: crate::data_types::PgMoney
358    ///
359    /// # Examples
360    ///
361    /// ```rust
362    /// # include!("../../doctest_setup.rs");
363    /// use diesel::data_types::Cents;
364    ///
365    /// table! {
366    ///     items {
367    ///         id -> Integer,
368    ///         name -> VarChar,
369    ///         price -> Money,
370    ///     }
371    /// }
372    ///
373    /// # fn main() {
374    /// #     use diesel::insert_into;
375    /// #     use self::items::dsl::*;
376    /// #     let connection = &mut connection_no_data();
377    /// #     diesel::sql_query("CREATE TABLE items (
378    /// #         id SERIAL PRIMARY KEY,
379    /// #         name VARCHAR NOT NULL,
380    /// #         price MONEY NOT NULL
381    /// #     )").execute(connection).unwrap();
382    /// let inserted_price = insert_into(items)
383    ///     .values((name.eq("Shiny Thing"), price.eq(Cents(123_456))))
384    ///     .returning(price)
385    ///     .get_result(connection);
386    /// assert_eq!(Ok(Cents(123_456)), inserted_price);
387    /// # }
388    /// ```
389    #[cfg(feature = "postgres_backend")]
390    #[derive(#[automatically_derived]
impl ::core::fmt::Debug for Money {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f, "Money")
    }
}Debug, #[automatically_derived]
impl ::core::clone::Clone for Money {
    #[inline]
    fn clone(&self) -> Money { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for Money { }Copy, #[automatically_derived]
impl ::core::default::Default for Money {
    #[inline]
    fn default() -> Money { Money {} }
}Default, const _: () =
    {
        use diesel;
        #[allow(non_camel_case_types)]
        impl diesel::query_builder::QueryId for Money {
            type QueryId = Money<>;
            const HAS_STATIC_QUERY_ID: bool = true;
            const IS_WINDOW_FUNCTION: bool = false;
        }
    };QueryId, const _: () =
    {
        use diesel;
        impl diesel::sql_types::SqlType for Money {
            type IsNull = diesel::sql_types::is_nullable::NotNull;
            const IS_ARRAY: bool = false;
        }
        impl diesel::sql_types::SingleValue for Money {}
        impl diesel::sql_types::HasSqlType<Money> for diesel::pg::Pg {
            fn metadata(_: &mut Self::MetadataLookup)
                -> diesel::pg::PgTypeMetadata {
                diesel::pg::PgTypeMetadata::new(790, 791)
            }
        }
    };SqlType)]
391    #[diesel(postgres_type(oid = 790, array_oid = 791))]
392    pub struct Money;
393
394    /// The [`MACADDR`](https://www.postgresql.org/docs/current/static/datatype-net-types.html) SQL type.
395    ///
396    /// ### [`ToSql`] impls
397    ///
398    /// - `[u8; 6]`
399    ///
400    /// ### [`FromSql`] impls
401    ///
402    /// - `[u8; 6]`
403    ///
404    /// [`ToSql`]: crate::serialize::ToSql
405    /// [`FromSql`]: crate::deserialize::FromSql
406    ///
407    /// # Examples
408    ///
409    /// ```rust
410    /// # include!("../../doctest_setup.rs");
411    /// table! {
412    ///     devices {
413    ///         id -> Integer,
414    ///         macaddr -> MacAddr,
415    ///     }
416    /// }
417    ///
418    /// # fn main() -> Result<(), Box<dyn std::error::Error>> {
419    /// #     use diesel::insert_into;
420    /// #     use self::devices::dsl::*;
421    /// #     let connection = &mut connection_no_data();
422    /// #     diesel::sql_query("CREATE TABLE devices (
423    /// #         id SERIAL PRIMARY KEY,
424    /// #         macaddr MACADDR NOT NULL
425    /// #     )").execute(connection)?;
426    /// let inserted_macaddr = insert_into(devices)
427    ///     .values(macaddr.eq([0x08, 0x00, 0x2b, 0x01, 0x02, 0x03]))
428    ///     .returning(macaddr)
429    ///     .get_result::<[u8; 6]>(connection)?;
430    /// assert_eq!([0x08, 0x00, 0x2b, 0x01, 0x02, 0x03], inserted_macaddr);
431    /// #     Ok(())
432    /// # }
433    /// ```
434    #[cfg(feature = "postgres_backend")]
435    #[derive(#[automatically_derived]
impl ::core::fmt::Debug for MacAddr {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f, "MacAddr")
    }
}Debug, #[automatically_derived]
impl ::core::clone::Clone for MacAddr {
    #[inline]
    fn clone(&self) -> MacAddr { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for MacAddr { }Copy, #[automatically_derived]
impl ::core::default::Default for MacAddr {
    #[inline]
    fn default() -> MacAddr { MacAddr {} }
}Default, const _: () =
    {
        use diesel;
        #[allow(non_camel_case_types)]
        impl diesel::query_builder::QueryId for MacAddr {
            type QueryId = MacAddr<>;
            const HAS_STATIC_QUERY_ID: bool = true;
            const IS_WINDOW_FUNCTION: bool = false;
        }
    };QueryId, const _: () =
    {
        use diesel;
        impl diesel::sql_types::SqlType for MacAddr {
            type IsNull = diesel::sql_types::is_nullable::NotNull;
            const IS_ARRAY: bool = false;
        }
        impl diesel::sql_types::SingleValue for MacAddr {}
        impl diesel::sql_types::HasSqlType<MacAddr> for diesel::pg::Pg {
            fn metadata(_: &mut Self::MetadataLookup)
                -> diesel::pg::PgTypeMetadata {
                diesel::pg::PgTypeMetadata::new(829, 1040)
            }
        }
    };SqlType)]
436    #[diesel(postgres_type(oid = 829, array_oid = 1040))]
437    pub struct MacAddr;
438
439    /// Alias for `MacAddr` to be able to use it with `diesel print-schema`.
440    pub type Macaddr = MacAddr;
441
442    /// The [`MACADDR8`](https://www.postgresql.org/docs/current/static/datatype-net-types.html) SQL type.
443    ///
444    /// ### [`ToSql`] impls
445    ///
446    /// - `[u8; 8]`
447    ///
448    /// ### [`FromSql`] impls
449    ///
450    /// - `[u8; 8]`
451    ///
452    /// [`ToSql`]: crate::serialize::ToSql
453    /// [`FromSql`]: crate::deserialize::FromSql
454    ///
455    /// # Examples
456    ///
457    /// ```rust
458    /// # include!("../../doctest_setup.rs");
459    /// table! {
460    ///     devices {
461    ///         id -> Integer,
462    ///         macaddr -> MacAddr8,
463    ///     }
464    /// }
465    ///
466    /// # fn main() -> Result<(), Box<dyn std::error::Error>> {
467    /// #     use diesel::insert_into;
468    /// #     use self::devices::dsl::*;
469    /// #     let connection = &mut connection_no_data();
470    /// #     diesel::sql_query("CREATE TABLE devices (
471    /// #         id SERIAL PRIMARY KEY,
472    /// #         macaddr MACADDR8 NOT NULL
473    /// #     )").execute(connection)?;
474    /// let inserted_macaddr = insert_into(devices)
475    ///     .values(macaddr.eq([0x08, 0x00, 0x2b, 0x01, 0x02, 0x03, 0x04, 0x05]))
476    ///     .returning(macaddr)
477    ///     .get_result::<[u8; 8]>(connection)?;
478    /// assert_eq!(
479    ///     [0x08, 0x00, 0x2b, 0x01, 0x02, 0x03, 0x04, 0x05],
480    ///     inserted_macaddr
481    /// );
482    /// #     Ok(())
483    /// # }
484    /// ```
485    #[cfg(feature = "postgres_backend")]
486    #[derive(#[automatically_derived]
impl ::core::fmt::Debug for MacAddr8 {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f, "MacAddr8")
    }
}Debug, #[automatically_derived]
impl ::core::clone::Clone for MacAddr8 {
    #[inline]
    fn clone(&self) -> MacAddr8 { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for MacAddr8 { }Copy, #[automatically_derived]
impl ::core::default::Default for MacAddr8 {
    #[inline]
    fn default() -> MacAddr8 { MacAddr8 {} }
}Default, const _: () =
    {
        use diesel;
        #[allow(non_camel_case_types)]
        impl diesel::query_builder::QueryId for MacAddr8 {
            type QueryId = MacAddr8<>;
            const HAS_STATIC_QUERY_ID: bool = true;
            const IS_WINDOW_FUNCTION: bool = false;
        }
    };QueryId, const _: () =
    {
        use diesel;
        impl diesel::sql_types::SqlType for MacAddr8 {
            type IsNull = diesel::sql_types::is_nullable::NotNull;
            const IS_ARRAY: bool = false;
        }
        impl diesel::sql_types::SingleValue for MacAddr8 {}
        impl diesel::sql_types::HasSqlType<MacAddr8> for diesel::pg::Pg {
            fn metadata(_: &mut Self::MetadataLookup)
                -> diesel::pg::PgTypeMetadata {
                diesel::pg::PgTypeMetadata::new(774, 775)
            }
        }
    };SqlType)]
487    #[diesel(postgres_type(oid = 774, array_oid = 775))]
488    pub struct MacAddr8;
489
490    /// Alias for `MacAddr` to be able to use it with `diesel print-schema`.
491    pub type Macaddr8 = MacAddr8;
492
493    /// The [`INET`](https://www.postgresql.org/docs/current/static/datatype-net-types.html) SQL type. This type can only be used with `feature = "network-address"` or `feature = "ipnet-address"`.
494    ///
495    /// ### [`ToSql`] impls
496    #[cfg_attr(
497        feature = "network-address",
498        doc = " - [`ipnetwork::IpNetwork`][IpNetwork]"
499    )]
500    #[cfg_attr(feature = "ipnet-address", doc = " - [`ipnet::IpNet`][IpNet]")]
501    #[cfg_attr(
502        not(any(feature = "network-address", feature = "ipnet-address")),
503        doc = "N/A"
504    )]
505    ///
506    /// ### [`FromSql`] impls
507    #[cfg_attr(
508        feature = "network-address",
509        doc = " - [`ipnetwork::IpNetwork`][IpNetwork]"
510    )]
511    #[cfg_attr(feature = "ipnet-address", doc = " - [`ipnet::IpNet`][IpNet]")]
512    #[cfg_attr(
513        not(any(feature = "network-address", feature = "ipnet-address")),
514        doc = "N/A"
515    )]
516    ///
517    /// [`ToSql`]: crate::serialize::ToSql
518    /// [`FromSql`]: crate::deserialize::FromSql
519    #[cfg_attr(
520        feature = "network-address",
521        doc = " [IpNetwork]: ipnetwork::IpNetwork"
522    )]
523    #[cfg_attr(feature = "ipnet-address", doc = " [IpNet]: ipnet::IpNet")]
524    ///
525    /// # Examples
526    ///
527    /// ```rust
528    /// # include!("../../doctest_setup.rs");
529    /// #
530    /// table! {
531    ///     clients {
532    ///         id -> Integer,
533    ///         ip_address -> Inet,
534    ///     }
535    /// }
536    ///
537    /// # #[cfg(any(feature = "network-address", feature = "ipnet-address"))]
538    /// # fn main() -> Result<(), Box<dyn std::error::Error>> {
539    ///
540    /// #     use diesel::insert_into;
541    /// #     use self::clients::dsl::*;
542    /// #     let connection = &mut connection_no_data();
543    /// #     diesel::sql_query("CREATE TABLE clients (
544    /// #         id SERIAL PRIMARY KEY,
545    /// #         ip_address INET NOT NULL
546    /// #     )").execute(connection)?;
547    /// // Parsing "ipnet::IpNet" would also work.
548    /// let addr = "10.1.9.32/32".parse::<ipnetwork::IpNetwork>()?;
549    /// let inserted_address = insert_into(clients)
550    ///     .values(ip_address.eq(&addr))
551    ///     .returning(ip_address)
552    ///     .get_result(connection)?;
553    /// assert_eq!(addr, inserted_address);
554    /// #     Ok(())
555    /// # }
556    /// #
557    /// # #[cfg(not(any(feature = "network-address", feature = "ipnet-address")))]
558    /// # fn main() {}
559    /// ```
560    #[cfg(feature = "postgres_backend")]
561    #[derive(#[automatically_derived]
impl ::core::fmt::Debug for Inet {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f, "Inet")
    }
}Debug, #[automatically_derived]
impl ::core::clone::Clone for Inet {
    #[inline]
    fn clone(&self) -> Inet { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for Inet { }Copy, #[automatically_derived]
impl ::core::default::Default for Inet {
    #[inline]
    fn default() -> Inet { Inet {} }
}Default, const _: () =
    {
        use diesel;
        #[allow(non_camel_case_types)]
        impl diesel::query_builder::QueryId for Inet {
            type QueryId = Inet<>;
            const HAS_STATIC_QUERY_ID: bool = true;
            const IS_WINDOW_FUNCTION: bool = false;
        }
    };QueryId, const _: () =
    {
        use diesel;
        impl diesel::sql_types::SqlType for Inet {
            type IsNull = diesel::sql_types::is_nullable::NotNull;
            const IS_ARRAY: bool = false;
        }
        impl diesel::sql_types::SingleValue for Inet {}
        impl diesel::sql_types::HasSqlType<Inet> for diesel::pg::Pg {
            fn metadata(_: &mut Self::MetadataLookup)
                -> diesel::pg::PgTypeMetadata {
                diesel::pg::PgTypeMetadata::new(869, 1041)
            }
        }
    };SqlType)]
562    #[diesel(postgres_type(oid = 869, array_oid = 1041))]
563    pub struct Inet;
564
565    /// The [`CIDR`](https://www.postgresql.org/docs/postgresql/static/datatype-net-types.html) SQL type. This type can only be used with `feature = "network-address"` or `feature = "ipnet-address"`.
566    ///
567    /// ### [`ToSql`] impls
568    #[cfg_attr(
569        feature = "network-address",
570        doc = " - [`ipnetwork::IpNetwork`][IpNetwork]"
571    )]
572    #[cfg_attr(feature = "ipnet-address", doc = " - [`ipnet::IpNet`][IpNet]")]
573    #[cfg_attr(
574        not(any(feature = "network-address", feature = "ipnet-address")),
575        doc = "N/A"
576    )]
577    ///
578    /// ### [`FromSql`] impls
579    #[cfg_attr(
580        feature = "network-address",
581        doc = " - [`ipnetwork::IpNetwork`][IpNetwork]"
582    )]
583    #[cfg_attr(feature = "ipnet-address", doc = " - [`ipnet::IpNet`][IpNet]")]
584    #[cfg_attr(
585        not(any(feature = "network-address", feature = "ipnet-address")),
586        doc = "N/A"
587    )]
588    ///
589    /// [`ToSql`]: crate::serialize::ToSql
590    /// [`FromSql`]: crate::deserialize::FromSql
591    #[cfg_attr(
592        feature = "network-address",
593        doc = " [IpNetwork]: ipnetwork::IpNetwork"
594    )]
595    #[cfg_attr(feature = "ipnet-address", doc = " [IpNet]: ipnet::IpNet")]
596    ///
597    /// # Examples
598    ///
599    /// ```rust
600    /// # #![allow(dead_code)]
601    /// # include!("../../doctest_setup.rs");
602    /// table! {
603    ///     clients {
604    ///         id -> Integer,
605    ///         ip_address -> Cidr,
606    ///     }
607    /// }
608    ///
609    /// # #[cfg(any(feature = "network-address", feature = "ipnet-address"))]
610    /// # fn main() -> Result<(), Box<dyn std::error::Error>> {
611    ///
612    /// #     use diesel::insert_into;
613    /// #     use self::clients::dsl::*;
614    /// #     let connection = &mut connection_no_data();
615    /// #     diesel::sql_query("CREATE TABLE clients (
616    /// #         id SERIAL PRIMARY KEY,
617    /// #         ip_address CIDR NOT NULL
618    /// #     )").execute(connection)?;
619    /// // Parsing "ipnet::IpNet" would also work.
620    /// let addr = "10.1.9.32/32".parse::<ipnetwork::IpNetwork>()?;
621    /// let inserted_addr = insert_into(clients)
622    ///     .values(ip_address.eq(&addr))
623    ///     .returning(ip_address)
624    ///     .get_result(connection)?;
625    /// assert_eq!(addr, inserted_addr);
626    /// #     Ok(())
627    /// # }
628    /// # #[cfg(not(any(feature = "network-address", feature = "ipnet-address")))]
629    /// # fn main() {}
630    /// ```
631    #[cfg(feature = "postgres_backend")]
632    #[derive(#[automatically_derived]
impl ::core::fmt::Debug for Cidr {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f, "Cidr")
    }
}Debug, #[automatically_derived]
impl ::core::clone::Clone for Cidr {
    #[inline]
    fn clone(&self) -> Cidr { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for Cidr { }Copy, #[automatically_derived]
impl ::core::default::Default for Cidr {
    #[inline]
    fn default() -> Cidr { Cidr {} }
}Default, const _: () =
    {
        use diesel;
        #[allow(non_camel_case_types)]
        impl diesel::query_builder::QueryId for Cidr {
            type QueryId = Cidr<>;
            const HAS_STATIC_QUERY_ID: bool = true;
            const IS_WINDOW_FUNCTION: bool = false;
        }
    };QueryId, const _: () =
    {
        use diesel;
        impl diesel::sql_types::SqlType for Cidr {
            type IsNull = diesel::sql_types::is_nullable::NotNull;
            const IS_ARRAY: bool = false;
        }
        impl diesel::sql_types::SingleValue for Cidr {}
        impl diesel::sql_types::HasSqlType<Cidr> for diesel::pg::Pg {
            fn metadata(_: &mut Self::MetadataLookup)
                -> diesel::pg::PgTypeMetadata {
                diesel::pg::PgTypeMetadata::new(650, 651)
            }
        }
    };SqlType)]
633    #[diesel(postgres_type(oid = 650, array_oid = 651))]
634    pub struct Cidr;
635
636    /// The [`"char"`] SQL type. This is a PostgreSQL specific type. Used for e.g. [setweight]. [Do not use in user tables].
637    ///
638    /// ### [`ToSql`] impls
639    ///
640    /// - [`u8`]
641    ///
642    /// ### [`FromSql`] impls
643    ///
644    /// - [`u8`]
645    ///
646    /// [`ToSql`]: crate::serialize::ToSql
647    /// [`FromSql`]: crate::deserialize::FromSql
648    /// [`u8`]: https://doc.rust-lang.org/nightly/std/primitive.u8.html
649    /// [`"char"`]: https://www.postgresql.org/docs/current/datatype-character.html#DATATYPE-CHARACTER-SPECIAL-TABLE
650    /// [setweight]: https://www.postgresql.org/docs/current/functions-textsearch.html
651    /// [Do not use in user tables]: https://www.postgresql.org/docs/current/datatype-character.html#DATATYPE-CHARACTER-SPECIAL-TABLE
652    #[cfg(feature = "postgres_backend")]
653    #[derive(#[automatically_derived]
impl ::core::fmt::Debug for CChar {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f, "CChar")
    }
}Debug, #[automatically_derived]
impl ::core::clone::Clone for CChar {
    #[inline]
    fn clone(&self) -> CChar { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for CChar { }Copy, #[automatically_derived]
impl ::core::default::Default for CChar {
    #[inline]
    fn default() -> CChar { CChar {} }
}Default, const _: () =
    {
        use diesel;
        #[allow(non_camel_case_types)]
        impl diesel::query_builder::QueryId for CChar {
            type QueryId = CChar<>;
            const HAS_STATIC_QUERY_ID: bool = true;
            const IS_WINDOW_FUNCTION: bool = false;
        }
    };QueryId, const _: () =
    {
        use diesel;
        impl diesel::sql_types::SqlType for CChar {
            type IsNull = diesel::sql_types::is_nullable::NotNull;
            const IS_ARRAY: bool = false;
        }
        impl diesel::sql_types::SingleValue for CChar {}
        impl diesel::sql_types::HasSqlType<CChar> for diesel::pg::Pg {
            fn metadata(_: &mut Self::MetadataLookup)
                -> diesel::pg::PgTypeMetadata {
                diesel::pg::PgTypeMetadata::new(18, 1002)
            }
        }
    };SqlType)]
654    #[diesel(postgres_type(oid = 18, array_oid = 1002))]
655    pub struct CChar;
656
657    /// The [`Citext`] SQL type. This is a PostgreSQL specific type.
658    ///
659    /// Strings must be valid UTF-8.
660    ///
661    /// ### [`ToSql`] impls
662    ///
663    /// - [`String`]
664    /// - [`&str`][str]
665    ///
666    /// ### [`FromSql`] impls
667    ///
668    /// - [`String`]
669    ///
670    /// [`ToSql`]: crate::serialize::ToSql
671    /// [`FromSql`]: crate::deserialize::FromSql
672    /// [`Citext`]: https://www.postgresql.org/docs/current/citext.html
673    #[cfg(feature = "postgres_backend")]
674    #[derive(#[automatically_derived]
impl ::core::fmt::Debug for Citext {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f, "Citext")
    }
}Debug, #[automatically_derived]
impl ::core::clone::Clone for Citext {
    #[inline]
    fn clone(&self) -> Citext { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for Citext { }Copy, #[automatically_derived]
impl ::core::default::Default for Citext {
    #[inline]
    fn default() -> Citext { Citext {} }
}Default, const _: () =
    {
        use diesel;
        #[allow(non_camel_case_types)]
        impl diesel::query_builder::QueryId for Citext {
            type QueryId = Citext<>;
            const HAS_STATIC_QUERY_ID: bool = true;
            const IS_WINDOW_FUNCTION: bool = false;
        }
    };QueryId, const _: () =
    {
        use diesel;
        impl diesel::sql_types::SqlType for Citext {
            type IsNull = diesel::sql_types::is_nullable::NotNull;
            const IS_ARRAY: bool = false;
        }
        impl diesel::sql_types::SingleValue for Citext {}
        impl diesel::sql_types::HasSqlType<Citext> for diesel::pg::Pg {
            fn metadata(lookup: &mut Self::MetadataLookup)
                -> diesel::pg::PgTypeMetadata {
                use diesel::pg::PgMetadataLookup;
                lookup.lookup_type("citext", None)
            }
        }
    };SqlType)]
675    #[diesel(postgres_type(name = "citext"))]
676    pub struct Citext;
677
678    /// The [`pg_lsn`] SQL type. This is a PostgreSQL specific type. Encodes a position in the PostgreSQL *Write Ahead Log* (WAL).
679    ///
680    /// ### [`ToSql`] impls
681    ///
682    /// - [`u64`]
683    ///
684    /// ### [`FromSql`] impls
685    ///
686    /// - [`u64`]
687    ///
688    /// [`ToSql`]: crate::serialize::ToSql
689    /// [`FromSql`]: crate::deserialize::FromSql
690    /// [`u64`]: https://doc.rust-lang.org/nightly/std/primitive.u64.html
691    /// [`pg_lsn`]: https://www.postgresql.org/docs/current/datatype-pg-lsn.html
692    #[cfg(feature = "postgres_backend")]
693    #[derive(#[automatically_derived]
impl ::core::fmt::Debug for PgLsn {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f, "PgLsn")
    }
}Debug, #[automatically_derived]
impl ::core::clone::Clone for PgLsn {
    #[inline]
    fn clone(&self) -> PgLsn { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for PgLsn { }Copy, #[automatically_derived]
impl ::core::default::Default for PgLsn {
    #[inline]
    fn default() -> PgLsn { PgLsn {} }
}Default, const _: () =
    {
        use diesel;
        #[allow(non_camel_case_types)]
        impl diesel::query_builder::QueryId for PgLsn {
            type QueryId = PgLsn<>;
            const HAS_STATIC_QUERY_ID: bool = true;
            const IS_WINDOW_FUNCTION: bool = false;
        }
    };QueryId, const _: () =
    {
        use diesel;
        impl diesel::sql_types::SqlType for PgLsn {
            type IsNull = diesel::sql_types::is_nullable::NotNull;
            const IS_ARRAY: bool = false;
        }
        impl diesel::sql_types::SingleValue for PgLsn {}
        impl diesel::sql_types::HasSqlType<PgLsn> for diesel::pg::Pg {
            fn metadata(_: &mut Self::MetadataLookup)
                -> diesel::pg::PgTypeMetadata {
                diesel::pg::PgTypeMetadata::new(3220, 3221)
            }
        }
    };SqlType)]
694    #[diesel(postgres_type(oid = 3220, array_oid = 3221))]
695    pub struct PgLsn;
696
697    #[doc(inline)]
698    pub use crate::sql_types::Jsonb;
699}
700
701mod ops {
702    use super::sql_types::*;
703    use crate::sql_types::ops::*;
704    use crate::sql_types::{Bigint, Interval};
705
706    impl Add for Timestamptz {
707        type Rhs = Interval;
708        type Output = Timestamptz;
709    }
710
711    impl Sub for Timestamptz {
712        type Rhs = Interval;
713        type Output = Timestamptz;
714    }
715
716    impl Add for Cidr {
717        type Rhs = Bigint;
718        type Output = Inet;
719    }
720
721    impl Add for Inet {
722        type Rhs = Bigint;
723        type Output = Inet;
724    }
725
726    impl Sub for Cidr {
727        type Rhs = Bigint;
728        type Output = Inet;
729    }
730
731    impl Sub for Inet {
732        type Rhs = Bigint;
733        type Output = Inet;
734    }
735}