Trait diesel::sql_types::HasSqlType
[−]
[src]
pub trait HasSqlType<ST>: TypeMetadata { fn metadata(lookup: &Self::MetadataLookup) -> Self::TypeMetadata; fn row_metadata(
out: &mut Vec<Self::TypeMetadata>,
lookup: &Self::MetadataLookup
) { ... } }
Indicates that a SQL type exists for a backend.
Deriving
This trait can be automatically derived by #[derive(SqlType)]
.
This derive will also implement NotNull
and SingleValue
.
When deriving this trait,
you need to specify how the type is represented on various backends.
You don't need to specify every backend,
only the ones supported by your type.
For PostgreSQL, add #[postgres(oid = "some_oid", array_oid = "some_oid")]
or #[postgres(type_name = "pg_type_name")]
if the OID is not stable.
For MySQL, specify which variant of MysqlType
should be used
by adding #[mysql_type = "Variant"]
.
For SQLite, specify which variant of SqliteType
should be used
by adding #[sqlite_type = "Variant"]
.
Example
#[derive(SqlType)] #[postgres(oid = "23", array_oid = "1007")] #[sqlite_type = "Integer"] #[mysql_type = "Long"] pub struct Integer;
Required Methods
fn metadata(lookup: &Self::MetadataLookup) -> Self::TypeMetadata
Fetch the metadata for the given type
This method may use lookup
to do dynamic runtime lookup. Implementors
of this method should not do dynamic lookup unless absolutely necessary
Provided Methods
fn row_metadata(
out: &mut Vec<Self::TypeMetadata>,
lookup: &Self::MetadataLookup
)
out: &mut Vec<Self::TypeMetadata>,
lookup: &Self::MetadataLookup
)
Fetch the metadata for a tuple representing an entire row
The default implementation of this method simply calls Self::metadata
.
You generally should not need to override this method.
However, if you are writing an implementation of HasSqlType
that
simply delegates to an inner type (for example, Nullable
does this),
then you should ensure that you delegate this method as well.
Implementors
impl HasSqlType<Bool> for Sqlite
impl HasSqlType<Bool> for Mysql
impl HasSqlType<Bool> for Pg
impl HasSqlType<Tinyint> for Mysql
impl HasSqlType<SmallInt> for Sqlite
impl HasSqlType<SmallInt> for Mysql
impl HasSqlType<SmallInt> for Pg
impl HasSqlType<Integer> for Sqlite
impl HasSqlType<Integer> for Mysql
impl HasSqlType<Integer> for Pg
impl HasSqlType<BigInt> for Sqlite
impl HasSqlType<BigInt> for Mysql
impl HasSqlType<BigInt> for Pg
impl HasSqlType<Float> for Sqlite
impl HasSqlType<Float> for Mysql
impl HasSqlType<Float> for Pg
impl HasSqlType<Double> for Sqlite
impl HasSqlType<Double> for Mysql
impl HasSqlType<Double> for Pg
impl HasSqlType<Numeric> for Sqlite
impl HasSqlType<Numeric> for Mysql
impl HasSqlType<Numeric> for Pg
impl HasSqlType<Text> for Sqlite
impl HasSqlType<Text> for Mysql
impl HasSqlType<Text> for Pg
impl HasSqlType<Binary> for Sqlite
impl HasSqlType<Binary> for Mysql
impl HasSqlType<Binary> for Pg
impl HasSqlType<Date> for Sqlite
impl HasSqlType<Date> for Mysql
impl HasSqlType<Date> for Pg
impl HasSqlType<Interval> for Pg
impl HasSqlType<Time> for Sqlite
impl HasSqlType<Time> for Mysql
impl HasSqlType<Time> for Pg
impl HasSqlType<Timestamp> for Sqlite
impl HasSqlType<Timestamp> for Mysql
impl HasSqlType<Timestamp> for Pg
impl HasSqlType<Datetime> for Mysql
impl<ST> HasSqlType<Unsigned<ST>> for Mysql where
Mysql: HasSqlType<ST>,impl<T> HasSqlType<Array<T>> for Pg where
Pg: HasSqlType<T>,impl HasSqlType<Oid> for Pg
impl HasSqlType<Timestamptz> for Pg
impl HasSqlType<Uuid> for Pg
impl HasSqlType<Json> for Pg
impl HasSqlType<Jsonb> for Pg
impl HasSqlType<Money> for Pg
impl HasSqlType<MacAddr> for Pg
impl HasSqlType<Inet> for Pg
impl HasSqlType<Cidr> for Pg
impl<T, DB> HasSqlType<Nullable<T>> for DB where
DB: Backend + HasSqlType<T>,
T: NotNull,impl<A, __DB> HasSqlType<(A,)> for __DB where
__DB: HasSqlType<A>,
__DB: Backend,impl<A, B, __DB> HasSqlType<(A, B)> for __DB where
__DB: HasSqlType<A>,
__DB: HasSqlType<B>,
__DB: Backend,impl<A, B, C, __DB> HasSqlType<(A, B, C)> for __DB where
__DB: HasSqlType<A>,
__DB: HasSqlType<B>,
__DB: HasSqlType<C>,
__DB: Backend,impl<A, B, C, D, __DB> HasSqlType<(A, B, C, D)> for __DB where
__DB: HasSqlType<A>,
__DB: HasSqlType<B>,
__DB: HasSqlType<C>,
__DB: HasSqlType<D>,
__DB: Backend,impl<A, B, C, D, E, __DB> HasSqlType<(A, B, C, D, E)> for __DB where
__DB: HasSqlType<A>,
__DB: HasSqlType<B>,
__DB: HasSqlType<C>,
__DB: HasSqlType<D>,
__DB: HasSqlType<E>,
__DB: Backend,impl<A, B, C, D, E, F, __DB> HasSqlType<(A, B, C, D, E, F)> for __DB where
__DB: HasSqlType<A>,
__DB: HasSqlType<B>,
__DB: HasSqlType<C>,
__DB: HasSqlType<D>,
__DB: HasSqlType<E>,
__DB: HasSqlType<F>,
__DB: Backend,impl<A, B, C, D, E, F, G, __DB> HasSqlType<(A, B, C, D, E, F, G)> for __DB where
__DB: HasSqlType<A>,
__DB: HasSqlType<B>,
__DB: HasSqlType<C>,
__DB: HasSqlType<D>,
__DB: HasSqlType<E>,
__DB: HasSqlType<F>,
__DB: HasSqlType<G>,
__DB: Backend,impl<A, B, C, D, E, F, G, H, __DB> HasSqlType<(A, B, C, D, E, F, G, H)> for __DB where
__DB: HasSqlType<A>,
__DB: HasSqlType<B>,
__DB: HasSqlType<C>,
__DB: HasSqlType<D>,
__DB: HasSqlType<E>,
__DB: HasSqlType<F>,
__DB: HasSqlType<G>,
__DB: HasSqlType<H>,
__DB: Backend,impl<A, B, C, D, E, F, G, H, I, __DB> HasSqlType<(A, B, C, D, E, F, G, H, I)> for __DB where
__DB: HasSqlType<A>,
__DB: HasSqlType<B>,
__DB: HasSqlType<C>,
__DB: HasSqlType<D>,
__DB: HasSqlType<E>,
__DB: HasSqlType<F>,
__DB: HasSqlType<G>,
__DB: HasSqlType<H>,
__DB: HasSqlType<I>,
__DB: Backend,impl<A, B, C, D, E, F, G, H, I, J, __DB> HasSqlType<(A, B, C, D, E, F, G, H, I, J)> for __DB where
__DB: HasSqlType<A>,
__DB: HasSqlType<B>,
__DB: HasSqlType<C>,
__DB: HasSqlType<D>,
__DB: HasSqlType<E>,
__DB: HasSqlType<F>,
__DB: HasSqlType<G>,
__DB: HasSqlType<H>,
__DB: HasSqlType<I>,
__DB: HasSqlType<J>,
__DB: Backend,impl<A, B, C, D, E, F, G, H, I, J, K, __DB> HasSqlType<(A, B, C, D, E, F, G, H, I, J, K)> for __DB where
__DB: HasSqlType<A>,
__DB: HasSqlType<B>,
__DB: HasSqlType<C>,
__DB: HasSqlType<D>,
__DB: HasSqlType<E>,
__DB: HasSqlType<F>,
__DB: HasSqlType<G>,
__DB: HasSqlType<H>,
__DB: HasSqlType<I>,
__DB: HasSqlType<J>,
__DB: HasSqlType<K>,
__DB: Backend,impl<A, B, C, D, E, F, G, H, I, J, K, L, __DB> HasSqlType<(A, B, C, D, E, F, G, H, I, J, K, L)> for __DB where
__DB: HasSqlType<A>,
__DB: HasSqlType<B>,
__DB: HasSqlType<C>,
__DB: HasSqlType<D>,
__DB: HasSqlType<E>,
__DB: HasSqlType<F>,
__DB: HasSqlType<G>,
__DB: HasSqlType<H>,
__DB: HasSqlType<I>,
__DB: HasSqlType<J>,
__DB: HasSqlType<K>,
__DB: HasSqlType<L>,
__DB: Backend,impl<A, B, C, D, E, F, G, H, I, J, K, L, M, __DB> HasSqlType<(A, B, C, D, E, F, G, H, I, J, K, L, M)> for __DB where
__DB: HasSqlType<A>,
__DB: HasSqlType<B>,
__DB: HasSqlType<C>,
__DB: HasSqlType<D>,
__DB: HasSqlType<E>,
__DB: HasSqlType<F>,
__DB: HasSqlType<G>,
__DB: HasSqlType<H>,
__DB: HasSqlType<I>,
__DB: HasSqlType<J>,
__DB: HasSqlType<K>,
__DB: HasSqlType<L>,
__DB: HasSqlType<M>,
__DB: Backend,impl<A, B, C, D, E, F, G, H, I, J, K, L, M, N, __DB> HasSqlType<(A, B, C, D, E, F, G, H, I, J, K, L, M, N)> for __DB where
__DB: HasSqlType<A>,
__DB: HasSqlType<B>,
__DB: HasSqlType<C>,
__DB: HasSqlType<D>,
__DB: HasSqlType<E>,
__DB: HasSqlType<F>,
__DB: HasSqlType<G>,
__DB: HasSqlType<H>,
__DB: HasSqlType<I>,
__DB: HasSqlType<J>,
__DB: HasSqlType<K>,
__DB: HasSqlType<L>,
__DB: HasSqlType<M>,
__DB: HasSqlType<N>,
__DB: Backend,impl<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, __DB> HasSqlType<(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O)> for __DB where
__DB: HasSqlType<A>,
__DB: HasSqlType<B>,
__DB: HasSqlType<C>,
__DB: HasSqlType<D>,
__DB: HasSqlType<E>,
__DB: HasSqlType<F>,
__DB: HasSqlType<G>,
__DB: HasSqlType<H>,
__DB: HasSqlType<I>,
__DB: HasSqlType<J>,
__DB: HasSqlType<K>,
__DB: HasSqlType<L>,
__DB: HasSqlType<M>,
__DB: HasSqlType<N>,
__DB: HasSqlType<O>,
__DB: Backend,impl<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, __DB> HasSqlType<(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P)> for __DB where
__DB: HasSqlType<A>,
__DB: HasSqlType<B>,
__DB: HasSqlType<C>,
__DB: HasSqlType<D>,
__DB: HasSqlType<E>,
__DB: HasSqlType<F>,
__DB: HasSqlType<G>,
__DB: HasSqlType<H>,
__DB: HasSqlType<I>,
__DB: HasSqlType<J>,
__DB: HasSqlType<K>,
__DB: HasSqlType<L>,
__DB: HasSqlType<M>,
__DB: HasSqlType<N>,
__DB: HasSqlType<O>,
__DB: HasSqlType<P>,
__DB: Backend,