Skip to content

[Bug]: Comparing a decimal/exponent string with an integer fails with a cast error ('10.0' = 10) #30694

Closed as duplicate

Description

@Ariznawlll

Bug or Feature Request

Bug

Description

Comparing a string containing a decimal point or exponent against an integer literal raises a hard cast error instead of comparing — MySQL compares both sides as DOUBLE and returns a boolean:

expression MatrixOne (v3.x @ b24d1b3) MySQL 8
'10' = 10 1 ✓ 1
' 10' = 10 1 ✓ 1
'10.0' = 10 ERROR 20203: invalid argument cast to int, bad value 10.0 1
'1e1' = 10 ERROR 20203: invalid argument cast to int, bad value 1e1 1
'10.5' = 10.5 1 ✓ (works because RHS is float) 1
'1e1' = 10.0 1 ✓ (works because RHS is float) 1

The raise-vs-compare outcome depends solely on whether the right-hand literal parses as int or as double — an invisible internal typing detail to the user. MySQL's documented behavior for str = number is a single rule: convert the string to DOUBLE, compare numerically (non-numeric strings compare as ~0 with no error in non-strict contexts; well-formed decimals like '10.0' simply equal).

Real-world blast radius:

  • Any ORM / templating / dynamic-SQL layer that binds a string-typed value against an integer parameter collapses from "match/no match" to a query-killing runtime error: WHERE bucket = '1e3' (string from JSON config), WHERE amount = '10.0' (string from a form field), in ('1.0','2.0') lists containing formatted numbers.
  • Exponent notation '1e1' is what float.to_string()-style serializers emit — a common accidental parameter format.
  • Note ' 10' (leading space) parses fine while '10.0' explodes — the acceptance set is narrower than every mainstream client convention.

Same failure occurs inside WHERE clauses and SELECT projections alike (independent of plan position), e.g.:

SELECT col_v = 10 FROM (SELECT '10.0' AS col_v) t WHERE col_v = 10;
-- ERROR 20203 (HY000): invalid argument cast to int, bad value 10.0

Steps to Reproduce

v3.x @ b24d1b3, macOS arm64, single-node:

SELECT '10.0' = 10;
-- ERROR 20203 (HY000): invalid argument cast to int, bad value 10.0
SELECT '1e1' = 10;
-- ERROR 20203 (HY000): invalid argument cast to int, bad value 1e1
-- controls:
SELECT '10.0' = 10.0;   -- 1 (works: RHS is float)
SELECT '1e1'  = 10.0;  -- 1 (works: RHS is float)
SELECT '10'   = 10;    -- 1 (works: pure-integer string)

Expected behavior

Per MySQL semantics, string = number comparisons convert the string operand to DOUBLE once and compare numerically: '10.0' = 10 → 1, '1e1' = 10 → 1. The int-cast path must not be used for cross-type comparison just because the RHS literal happens to be integral-typed.

Versions

  • MatrixOne commit b24d1b3 (2026-10-16), v3.x dev, macOS arm64

Additional context

  • Also verified related strictness divergence for completeness: SELECT CAST('abc' AS SIGNED) errors in MatrixOne but yields 0 with a warning in MySQL non-strict / classic mode — that part is arguably intentional modern strictness (and matches MySQL strict mode's 1292), so this issue is scoped to the comparison-operator typing rule, which deviates from MySQL in all modes.

Activity

  1. added
    kind/bug
    on Oct 21, 2026
  2. added this to the MO-202611 milestone on Oct 21, 2026
  3. XuPeng-SH commented on Oct 22, 2026

    @XuPeng-SH
    Contributor

    合并跟踪到 #30730。此 issue 的关键复现('10.0' = 10、'1e1' = 10 在整数路径报 cast error)已补入主 issue 的行为矩阵;保留的目标是统一不同操作符和 SQL mode 下的隐式字符串转数值策略。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/bug

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions