fix(chat): decode pg_class.reltuples as f32 in sample_data probe
Some checks failed
CI / lint-and-build (push) Failing after 1m15s

pg_class.reltuples is `real` (FLOAT4). Reading it as f64 via query_scalar made
the sample_data tool fail with a sqlx type-mismatch ("f64 (FLOAT8) is not
compatible with FLOAT4") before any rows were fetched. Decode as f32 and widen.
This commit is contained in:
2026-05-23 18:17:55 +03:00
parent ff212e4d0b
commit c03e887b71

View File

@@ -899,7 +899,9 @@ async fn build_sample_sql_postgres(
limit: u32,
) -> TuskResult<String> {
let pool = state.get_pool(connection_id).await?;
let reltuples: f64 = sqlx::query_scalar(
// pg_class.reltuples is `real` (FLOAT4); decode as f32 then widen — sqlx is
// strict and reading it directly as f64 fails with a type-mismatch error.
let reltuples: f64 = sqlx::query_scalar::<_, f32>(
"SELECT c.reltuples FROM pg_class c JOIN pg_namespace n ON c.relnamespace = n.oid \
WHERE n.nspname = $1 AND c.relname = $2",
)
@@ -908,7 +910,7 @@ async fn build_sample_sql_postgres(
.fetch_optional(&pool)
.await
.map_err(TuskError::Database)?
.unwrap_or(0.0);
.unwrap_or(0.0) as f64;
let qualified = format!("{}.{}", escape_ident(schema), escape_ident(table));
if reltuples > 0.0 {