feat: Unify Debug implementations across PgRow, MySqlRow and SqliteRow#3890
Conversation
Debug implementations across PgRow, MySqlRow and SqliteRowDebug implementations across PgRow, MySqlRow and SqliteRow
|
This actually shouldn't be considered a breaking change because the The only time the change of |
Agreed in principle. My thinking was that it'd be a bit of an inconvenience if folks were using debug snapshots in their test suites and would now have to audit and commit all the changes. Not the end of the world though. |
…qliteRow` (transact-rs#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
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.