InCondition collects subquery into Set<Result> — IN (SELECT …) always returns empty (original) (raw)
Affected version: 26.4.2 (confirmed still present in 26.5.1)
Component: com.arcadedb.query.sql.parser.InCondition
Summary
executeQuery materialises the subquery into a Set<Result>. The filter then calls set.contains(scalar) which testsscalar.equals(<Result>) — always false. The downstream branch with the single-property unwrapping never runs because the Set fast-path short-circuits.
Code
engine/com/arcadedb/query/sql/parser/InCondition.java:135–143, 59–63
protected static Object executeQuery(SelectStatement rightStatement, CommandContext context) { ResultSet result = rightStatement.execute(context.getDatabase(), context.getInputParameters()); return result.stream().collect(Collectors.toSet()); } … if (iRight instanceof Set<?> set) return set.contains(iLeft);
Impact
Every WHERE x IN (SELECT y FROM …) evaluates to false for every row, returning empty results. NOT IN returns everything. Silent wrong results — no exception.
Suggested fix
Project the subquery to scalars at collection time (unwrap a single-property Result to its value), or skip the Set fast path and always go through the unwrapping loop.