fix(chat): decode pg_class.reltuples as f32 in sample_data probe
Some checks failed
CI / lint-and-build (push) Failing after 1m15s
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:
@@ -899,7 +899,9 @@ async fn build_sample_sql_postgres(
|
|||||||
limit: u32,
|
limit: u32,
|
||||||
) -> TuskResult<String> {
|
) -> TuskResult<String> {
|
||||||
let pool = state.get_pool(connection_id).await?;
|
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 \
|
"SELECT c.reltuples FROM pg_class c JOIN pg_namespace n ON c.relnamespace = n.oid \
|
||||||
WHERE n.nspname = $1 AND c.relname = $2",
|
WHERE n.nspname = $1 AND c.relname = $2",
|
||||||
)
|
)
|
||||||
@@ -908,7 +910,7 @@ async fn build_sample_sql_postgres(
|
|||||||
.fetch_optional(&pool)
|
.fetch_optional(&pool)
|
||||||
.await
|
.await
|
||||||
.map_err(TuskError::Database)?
|
.map_err(TuskError::Database)?
|
||||||
.unwrap_or(0.0);
|
.unwrap_or(0.0) as f64;
|
||||||
|
|
||||||
let qualified = format!("{}.{}", escape_ident(schema), escape_ident(table));
|
let qualified = format!("{}.{}", escape_ident(schema), escape_ident(table));
|
||||||
if reltuples > 0.0 {
|
if reltuples > 0.0 {
|
||||||
|
|||||||
Reference in New Issue
Block a user