[Breaking Change] Unify Debug
implementations across PgRow
, MySqlRow
and SqliteRow
#3890
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Context
In a personal code base I currently maintain a
Row
implementation calledDebugRow
as a catch-all type for queries so that I can use itsDebug
implementation for snapshot testing (using the great insta crate).While upgrading the version of sqlx I noticed there was now a useful
Debug
implementation forPgRow
(#2917) which had me hoping there was an equivalent forSqliteRow
, but after digging through the code I found outPgRow
has a customDebug
which prints out the contents of the row usingdebug_map()
MySqlRow
uses a derivedDebug
SqliteRow
does not implementDebug
Rather than implement similar logic to
PgRow
forSqliteRow
I figured it might be better to unify the implementations as the various traits (e.g.Row
,Database
,TypeChecking
) provide everything needed to implementPgRow
's version generically.Also related: #150
Proposed changes
sqlx_core::row::debug_row
functionDebug
onSqliteRow
PgRow
'sDebug
implementationMySqlRow
's derivedDebug
Is this a breaking change?
Yes.
PgRow
'sDebug
implementation changes a little bit because of the use ofstd::any::type_name
(This could be avoided by passing a name to
debug_row
instead but is definitely less elegant)MySqlRow
'sDebug
implementation would be completely differentIf this is too ambitious of a change I'm happy to pare it down to just the
SqliteRow
change as that's fundamentally what I'm after.