Reviews sqlx database code for compile-time query checking, connection pool management, migration patterns, and PostgreSQL-specific usage. Use when reviewing Rust code that uses sqlx, database queries, connection pools, or migrations. Covers offline mode, type mapping, and transaction patterns.
runtime-tokio, tls-rustls/tls-native-tls, postgres/mysql/sqlite, uuid, chrono, json, migrate)query!, query_as!) vs runtime (query, query_as)Report findings as:
[FILE:LINE] ISSUE_TITLE
Severity: Critical | Major | Minor | Informational
Description of the issue and why it matters.
| Issue Type | Reference |
|---|---|
| Query macros, bind parameters, result mapping | references/queries.md |
| Migrations, pool config, transaction patterns | references/migrations.md |
query!, query_as!) used where possiblesqlx.toml or DATABASE_URL configured for offline compile-time checking$1, $2)query_as! maps to named structs, not anonymous records, for public APIs.fetch_one(), .fetch_optional(), .fetch_all() chosen appropriately.fetch() (streaming) used for large result setsPgPool shared via Arc or framework state (not created per-request)pool.begin() used for multi-statement operationstx.begin()) if neededsqlx::Type derives match database column typesUuid, DateTime<Utc>, Decimal types used (not strings for structured data)Option<T> used for nullable columnsserde_json::Value used for JSONB columnsYYYYMMDDHHMMSS_description.sql)sqlx::migrate!() called at application startupquery()) where compile-time (query!()) could verify correctness.fetch_all() on potentially large tables.fetch_optional() (using .fetch_one() then handling error for "not found")SELECT * when only specific columns neededquery_as! for type-safe result mappingquery() for dynamic queries — Compile-time checking doesn't work with dynamic SQLsqlx::FromRow derive — Valid alternative to query_as! for reusable row typesTEXT columns for enum storage — Valid with sqlx::Type derive, simpler than custom SQL types.execute() ignoring row count — Acceptable for idempotent operations (upserts, deletes)Load and follow beagle-rust:review-verification-protocol before reporting any issue.