Skip to content

Conversation

@lovasoa
Copy link
Collaborator

@lovasoa lovasoa commented Jan 12, 2026

Prevent panic in mismatched_types error construction for Any database by avoiding Type::type_info() call.

The mismatched_types error path would panic when DB was Any because Type<Any>::type_info() is intentionally unimplemented!(). This change introduces a helper function to check if the database is Any and, if so, returns "<unknown>" for the Rust SQL type instead of calling the panicking type_info(). A regression test is added to confirm the fix.


Open in Cursor Open in Web

Co-authored-by: contact <contact@ophir.dev>
@cursor
Copy link

cursor bot commented Jan 12, 2026

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

Co-authored-by: contact <contact@ophir.dev>
@lovasoa
Copy link
Collaborator Author

lovasoa commented Jan 12, 2026

@cursoragent ensure no clippy warnings, whatever the selected feature set:

   Compiling sqlx-core-oldapi v0.6.51 (/home/runner/work/sqlx-oldapi/sqlx-oldapi/sqlx-core)
error: type parameter `DB` goes unused in function definition
  --> sqlx-core/src/error.rs:76:13
   |
76 | fn is_any_db<DB: Database>() -> bool {
   |             ^^^^^^^^^^^^^^ help: consider removing the parameter
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.92.0/index.html#extra_unused_type_parameters
   = note: `-D clippy::extra-unused-type-parameters` implied by `-D warnings`
   = help: to override `-D warnings` add `#[allow(clippy::extra_unused_type_parameters)]`

error: could not compile `sqlx-core-oldapi` (lib) due to 1 previous error
warning: build failed, waiting for other jobs to finish...
Process completed with exit code 101.

@cursor
Copy link

cursor bot commented Jan 12, 2026

The clippy error is fixed by ensuring the “fallback” is_any_db() still uses the DB type parameter even when crate::any is compiled out:

  • In the non-Any cfg branch, is_any_db<DB>() now does let _ = std::any::TypeId::of::<DB>(); and returns false, so DB is no longer “unused” and clippy::extra_unused_type_parameters won’t fire.

I also verified clippy is clean with -D warnings (and with targets enabled so the runtime feature is present for sqlx-rt):

  • cargo clippy -p sqlx-core-oldapi --features "any,postgres" --all-targets -- -D warnings
  • cargo clippy -p sqlx-core-oldapi --features "postgres" --all-targets -- -D warnings

Open in Cursor Open in Web

Learn more about Cursor Agents

Co-authored-by: contact <contact@ophir.dev>
@lovasoa lovasoa marked this pull request as ready for review January 12, 2026 17:47
@lovasoa lovasoa merged commit 76a804b into main Jan 12, 2026
65 checks passed
@lovasoa lovasoa deleted the cursor/sqlx-type-info-crash-00b3 branch January 13, 2026 15:06
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.

3 participants