Skip to content

[severity/p0][kind/bug] DECIMAL and YEAR columns silently render as NULL #508

Closed

Description

@EVWorth

Found while investigating #502. Measured against a live MySQL 8 through the real QueryExecutor::execute path, not inferred.

Problem

COLUMN d    type=DECIMAL   value=Null      -- DECIMAL(20,4), actual value 1.5
COLUMN n    type=DECIMAL   value=Null      -- NUMERIC(10,2), actual value 2.5
COLUMN yr   type=YEAR      value=Null      -- YEAR, actual value 2026
COLUMN f    type=FLOAT     value=Float(3.5)
COLUMN vc   type=VARCHAR   value=String("text")

Every DECIMAL/NUMERIC and YEAR column displays as NULL, indistinguishable from a real NULL. Nothing is logged. Grid, exports, copy-as-INSERT and generated UPDATE/DELETE predicates are all affected — a WHERE clause built from a NULL-looking decimal will not match the intended row.

DECIMAL is the type used for money, so this is likely to hit real data.

Cause

extract_value in crates/mas-core/src/query/executor.rs decodes each value into a typed Rust enum, then swallows any decode error:

"FLOAT" | "DOUBLE" | "DECIMAL" | "REAL" => row
    .try_get::<Option<f64>, _>(index)
    .ok()            // <-- decode error discarded
    .flatten()       // <-- becomes None
    .map(SqlValue::Float)
    .unwrap_or(SqlValue::Null),   // <-- surfaces as NULL

sqlx refuses DECIMAL outright — the crate is built with default-features = false and neither the bigdecimal nor rust_decimal feature:

as f64:    Err("mismatched types; Rust type `f64` (as SQL type `DOUBLE`) is not compatible with SQL type `DECIMAL`")
as String: Err("mismatched types; Rust type `String` (as SQL type `VARCHAR`) is not compatible with SQL type `DECIMAL`")

YEAR fails the same way: it is matched in the DATE | DATETIME | TIMESTAMP | TIME | YEAR arm, which asks for chrono::DateTime<Utc>, and a bare year will not decode as a timestamp.

The .ok().flatten() pattern is the underlying fault: a decode failure is made indistinguishable from a legitimate SQL NULL. Any type sqlx cannot decode into the chosen Rust type disappears silently, so this class of bug can recur with any new type.

Fix directions

  1. Stop discarding the error. At minimum, fall back to the raw text (or a loud placeholder) and log, so an unsupported type is visible rather than silently NULL. Cheapest, and prevents recurrence.
  2. Enable sqlx's rust_decimal or bigdecimal feature so DECIMAL decodes, and carry it as a string to preserve exactness — decoding it into f64 would defeat the point of the type.
  3. Fix the YEAR arm — decode as an integer rather than a timestamp.

(1) is worth doing regardless of how #502 is resolved, since it converts a whole class of silent data loss into something noticeable.

Related

#502 (BIGINT precision) is the same root cause seen from the other side: the pipeline converts values into a closed set of Rust types instead of carrying what the server sent. Both SQLyog (C++) and Beekeeper Studio (Electron/TS) avoid this by never converting — see the discussion there.

Activity

  1. added
    bug
    severity/p0
    kind/bug
    on Aug 27, 2026
  2. added a commit that references this issue on Aug 28, 2026
    426d0fe
  3. added 2 commits that reference this issue on Aug 28, 2026
    a0d34ab
    1d2f883
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugkind/bugseverity/p0

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions