mirror of
https://github.com/launchbadge/sqlx
synced 2024-11-10 06:24:16 +00:00
chore(postgres): include nullables query in error
This commit is contained in:
parent
4fb2dcbe97
commit
56d0225378
3 changed files with 19 additions and 8 deletions
|
@ -312,11 +312,16 @@ impl From<crate::migrate::MigrateError> for Error {
|
|||
/// Format an error message as a `Protocol` error
|
||||
#[macro_export]
|
||||
macro_rules! err_protocol {
|
||||
($expr:expr) => {
|
||||
$crate::error::Error::Protocol($expr.into())
|
||||
};
|
||||
|
||||
($fmt:expr, $($arg:tt)*) => {
|
||||
$crate::error::Error::Protocol(format!($fmt, $($arg)*))
|
||||
($($fmt_args:tt)*) => {
|
||||
$crate::error::Error::Protocol(
|
||||
format!(
|
||||
"{} ({}:{})",
|
||||
// Note: the format string needs to be unmodified (e.g. by `concat!()`)
|
||||
// for implicit formatting arguments to work
|
||||
format_args!($($fmt_args)*),
|
||||
module_path!(),
|
||||
line!(),
|
||||
)
|
||||
)
|
||||
};
|
||||
}
|
||||
|
|
|
@ -466,7 +466,13 @@ WHERE rngtypid = $1
|
|||
let mut nullables: Vec<Option<bool>> = nullable_query
|
||||
.build_query_scalar()
|
||||
.fetch_all(&mut *self)
|
||||
.await?;
|
||||
.await
|
||||
.map_err(|e| {
|
||||
err_protocol!(
|
||||
"error from nullables query: {e}; query: {:?}",
|
||||
nullable_query.sql()
|
||||
)
|
||||
})?;
|
||||
|
||||
// If the server is CockroachDB or Materialize, skip this step (#1248).
|
||||
if !self.stream.parameter_statuses.contains_key("crdb_version")
|
||||
|
|
|
@ -27,7 +27,7 @@ impl PgBufMutExt for Vec<u8> {
|
|||
let size_result = write_result.and_then(|_| {
|
||||
let size = self.len() - offset;
|
||||
i32::try_from(size)
|
||||
.map_err(|_| err_protocol!("message size out of range for Pg protocol: {size"))
|
||||
.map_err(|_| err_protocol!("message size out of range for protocol: {size}"))
|
||||
});
|
||||
|
||||
match size_result {
|
||||
|
|
Loading…
Reference in a new issue