Skip to content

[OPENJPA-3050] Return null for arithmetic with a null operand evaluated in memory - #257

Merged
solomax merged 1 commit into
masterfrom
OPENJPA-3050
Nov 3, 2026
Merged

solomax merged 1 commit into
masterfrom
OPENJPA-3050

Conversation

@rzo1

@rzo1 rzo1 commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

https://issues.apache.org/jira/browse/OPENJPA-3050

In memory, arithmetic with a NULL operand treated the null as 0, so -n.intB returned 0 and n.intA / n.intB failed with a division by zero, while the database returns NULL.

  • Filters.op returns null when an operand is null (+ - * / MOD POWER ROUND).
  • ABS, SQRT, SIGN, CEILING, FLOOR, EXP and LN return null for null instead of throwing, which matters when nested, e.g. in COALESCE.
  • Same for the in-memory bulk update path in JDBCStoreQuery.
  • SUM/AVG still skip nulls.
  • Migration note added. In-memory <> against null keeps its existing behaviour (true when one side is null), which the note mentions.

New TestNullArithmeticInMemory. Full suites pass on Derby and H2.

@rzo1 rzo1 self-assigned this Nov 2, 2026
@rzo1
rzo1 requested review from cristof and solomax November 2, 2026 19:32
@solomax
solomax merged commit 10bc16d into master Nov 3, 2026
4 checks passed
@solomax
solomax deleted the OPENJPA-3050 branch November 3, 2026 02:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants