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