mirror of
https://github.com/launchbadge/sqlx.git
synced 2025-10-03 15:55:45 +00:00
chore(postgres): include nullables query in error
This commit is contained in:
parent
4fb2dcbe97
commit
56d0225378
@ -312,11 +312,16 @@ impl From<crate::migrate::MigrateError> for Error {
|
|||||||
/// Format an error message as a `Protocol` error
|
/// Format an error message as a `Protocol` error
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! err_protocol {
|
macro_rules! err_protocol {
|
||||||
($expr:expr) => {
|
($($fmt_args:tt)*) => {
|
||||||
$crate::error::Error::Protocol($expr.into())
|
$crate::error::Error::Protocol(
|
||||||
};
|
format!(
|
||||||
|
"{} ({}:{})",
|
||||||
($fmt:expr, $($arg:tt)*) => {
|
// Note: the format string needs to be unmodified (e.g. by `concat!()`)
|
||||||
$crate::error::Error::Protocol(format!($fmt, $($arg)*))
|
// 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
|
let mut nullables: Vec<Option<bool>> = nullable_query
|
||||||
.build_query_scalar()
|
.build_query_scalar()
|
||||||
.fetch_all(&mut *self)
|
.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 the server is CockroachDB or Materialize, skip this step (#1248).
|
||||||
if !self.stream.parameter_statuses.contains_key("crdb_version")
|
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_result = write_result.and_then(|_| {
|
||||||
let size = self.len() - offset;
|
let size = self.len() - offset;
|
||||||
i32::try_from(size)
|
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 {
|
match size_result {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user