Skip to content

feat: Unify Debug implementations across PgRow, MySqlRow and SqliteRow #3890

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 7, 2025

Conversation

davidcornu
Copy link
Contributor

@davidcornu davidcornu commented Jun 6, 2025

Context

In a personal code base I currently maintain a Row implementation called DebugRow as a catch-all type for queries so that I can use its Debug implementation for snapshot testing (using the great insta crate).

While upgrading the version of sqlx I noticed there was now a useful Debug implementation for PgRow (#2917) which had me hoping there was an equivalent for SqliteRow, but after digging through the code I found out

  • PgRow has a custom Debug which prints out the contents of the row using debug_map()
  • MySqlRow uses a derived Debug
  • SqliteRow does not implement Debug

Rather than implement similar logic to PgRow for SqliteRow I figured it might be better to unify the implementations as the various traits (e.g. Row, Database, TypeChecking) provide everything needed to implement PgRow's version generically.

Also related: #150

Proposed changes

  1. Introduce a new sqlx_core::row::debug_row function
  2. Use (1) to implement Debug on SqliteRow
  3. Use (1) to replace PgRow's Debug implementation
  4. Use (1) to replace MySqlRow's derived Debug

Is this a breaking change?

Yes.

  1. PgRow's Debug implementation changes a little bit because of the use of std::any::type_name
    (This could be avoided by passing a name to debug_row instead but is definitely less elegant)
  2. MySqlRow's Debug implementation would be completely different

If 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.

@abonander abonander changed the title [Breaking Change] Unify Debug implementations across PgRow, MySqlRow and SqliteRow feat: Unify Debug implementations across PgRow, MySqlRow and SqliteRow Jul 7, 2025
@abonander
Copy link
Collaborator

This actually shouldn't be considered a breaking change because the Debug output of a type should generally not be considered to be stable. It's right there in the name: it's meant for debugging, not necessarily something to be depended upon in production.

The only time the change of Debug output should be considered a breaking change is if it's explicitly promised to be stable.

@abonander abonander merged commit 2702b98 into launchbadge:main Jul 7, 2025
84 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants