fix(executor): handle subqueries in comparisons and per-row UPDATE expressions

- Add missing nkSubquery case in lowerExpr so scalar subqueries
  (e.g. budget > (SELECT AVG(budget) FROM projects)) are lowered
  correctly instead of being treated as NULL literals.
- Move UPDATE SET expression evaluation inside the row loop so
  column references (e.g. salary + 5000) are resolved against the
  current row, fixing type validation failures.
- Make irAdd/irSub/irMul/irDiv return integer strings when the
  result is a whole number, avoiding spurious float output for INT
  columns (e.g. MERGE UPDATE qty = 100 + 50 now yields 150).

These fix regressions introduced by switching NULL representation
from empty string to \N, which exposed the pre-existing bugs above.

Refs: issue #9, issue #10
This commit is contained in:
2026-05-17 03:29:25 +03:00
parent 073ec41652
commit 5231724e77
2 changed files with 36 additions and 17 deletions
+1 -1
View File
@@ -2997,7 +2997,7 @@ suite "MERGE Statement":
check r.success
check r.affectedRows == 1
let verify = qexec.executeQuery(ctx, parse("SELECT * FROM inventory WHERE sku = 'SKU001'"))
check verify.rows[0]["qty"] == "150.0"
check verify.rows[0]["qty"] == "150"
test "MERGE WHEN NOT MATCHED INSERT":
let r = qexec.executeQuery(ctx, parse("""