mirror of
https://github.com/launchbadge/sqlx.git
synced 2026-03-19 08:39:44 +00:00
feat: Unify Debug implementations across PgRow, MySqlRow and SqliteRow (#3890)
* Introduce `debug_row` function * Use `debug_row` to implement `Debug` for `SqliteRow` * Use `debug_row` in `PgRow`'s `Debug` implementation * Match `MySqlRow`'s `Debug` implementation
This commit is contained in:
@@ -4,10 +4,8 @@ use crate::message::DataRow;
|
||||
use crate::statement::PgStatementMetadata;
|
||||
use crate::value::PgValueFormat;
|
||||
use crate::{PgColumn, PgValueRef, Postgres};
|
||||
use sqlx_core::row::debug_row;
|
||||
pub(crate) use sqlx_core::row::Row;
|
||||
use sqlx_core::type_checking::TypeChecking;
|
||||
use sqlx_core::value::ValueRef;
|
||||
use std::fmt::Debug;
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Implementation of [`Row`] for PostgreSQL.
|
||||
@@ -51,25 +49,8 @@ impl ColumnIndex<PgRow> for &'_ str {
|
||||
}
|
||||
}
|
||||
|
||||
impl Debug for PgRow {
|
||||
impl std::fmt::Debug for PgRow {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "PgRow ")?;
|
||||
|
||||
let mut debug_map = f.debug_map();
|
||||
for (index, column) in self.columns().iter().enumerate() {
|
||||
match self.try_get_raw(index) {
|
||||
Ok(value) => {
|
||||
debug_map.entry(
|
||||
&column.name,
|
||||
&Postgres::fmt_value_debug(&<PgValueRef as ValueRef>::to_owned(&value)),
|
||||
);
|
||||
}
|
||||
Err(error) => {
|
||||
debug_map.entry(&column.name, &format!("decode error: {error:?}"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
debug_map.finish()
|
||||
debug_row(self, f)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user