feat: 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
Rowimplementation calledDebugRowas a catch-all type for queries so that I can use itsDebugimplementation for snapshot testing (using the great insta crate).While upgrading the version of sqlx I noticed there was now a useful
Debugimplementation forPgRow(#2917) which had me hoping there was an equivalent forSqliteRow, but after digging through the code I found outPgRowhas a customDebugwhich prints out the contents of the row usingdebug_map()MySqlRowuses a derivedDebugSqliteRowdoes not implementDebugRather than implement similar logic to
PgRowforSqliteRowI 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_rowfunctionDebugonSqliteRowPgRow'sDebugimplementationMySqlRow's derivedDebugIs this a breaking change?
Yes.
PgRow'sDebugimplementation changes a little bit because of the use ofstd::any::type_name(This could be avoided by passing a name to
debug_rowinstead but is definitely less elegant)MySqlRow'sDebugimplementation would be completely differentIf this is too ambitious of a change I'm happy to pare it down to just the
SqliteRowchange as that's fundamentally what I'm after.