mirror of
https://github.com/launchbadge/sqlx.git
synced 2025-12-29 21:00:54 +00:00
Merge branch 'main' into sqlx-toml
# Conflicts: # Cargo.lock
This commit is contained in:
commit
017ffcea86
1576
Cargo.lock
generated
1576
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -64,6 +64,7 @@ pub trait Row: Unpin + Send + Sync + 'static {
|
||||
/// See [`try_get`](Self::try_get) for a non-panicking version.
|
||||
///
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
fn get<'r, T, I>(&'r self, index: I) -> T
|
||||
where
|
||||
I: ColumnIndex<Self>,
|
||||
|
||||
@ -91,11 +91,17 @@ where
|
||||
|
||||
match T::decode(value.as_ref()) {
|
||||
Ok(value) => Debug::fmt(&value, f),
|
||||
Err(e) => f.write_fmt(format_args!(
|
||||
"(error decoding SQL type {} as {}: {e:?})",
|
||||
info.name(),
|
||||
std::any::type_name::<T>()
|
||||
)),
|
||||
Err(e) => {
|
||||
if e.is::<crate::error::UnexpectedNullError>() {
|
||||
f.write_str("NULL")
|
||||
} else {
|
||||
f.write_fmt(format_args!(
|
||||
"(error decoding SQL type {} as {}: {e:?})",
|
||||
info.name(),
|
||||
std::any::type_name::<T>()
|
||||
))
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
@ -179,6 +179,18 @@
|
||||
//! enum Mood { Sad = 0, Ok = 1, Happy = 2 }
|
||||
//! ```
|
||||
//!
|
||||
//! Rust enumerations may also be defined to be represented as a string using `type_name = "text"`.
|
||||
//! The following type expects a SQL type of `TEXT` and will convert to/from the Rust enumeration.
|
||||
//!
|
||||
//! ```rust,ignore
|
||||
//! #[derive(sqlx::Type)]
|
||||
//! #[sqlx(type_name = "text")]
|
||||
//! enum Mood { Sad, Ok, Happy }
|
||||
//! ```
|
||||
//!
|
||||
//! Note that an error can occur if you attempt to decode a value not contained within the enum
|
||||
//! definition.
|
||||
//!
|
||||
|
||||
use crate::type_info::PgTypeKind;
|
||||
use crate::{PgTypeInfo, Postgres};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user