浏览代码

ESQL: Fix AttributeSet#add() returning the opposite expected value (#117367) (#117462)

Set/Collection#add() is supposed to return `true` if the collection changed (If it actually added something).
In this case, it must return if the old value is null.

Extracted from https://github.com/elastic/elasticsearch/pull/114317 (Where it's being used)
Iván Cea Fontenla 11 月之前
父节点
当前提交
b251970890

+ 1 - 1
x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/AttributeSet.java

@@ -113,7 +113,7 @@ public class AttributeSet implements Set<Attribute> {
 
     @Override
     public boolean add(Attribute e) {
-        return delegate.put(e, PRESENT) != null;
+        return delegate.put(e, PRESENT) == null;
     }
 
     @Override

+ 1 - 1
x-pack/plugin/ql/src/main/java/org/elasticsearch/xpack/ql/expression/AttributeSet.java

@@ -113,7 +113,7 @@ public class AttributeSet implements Set<Attribute> {
 
     @Override
     public boolean add(Attribute e) {
-        return delegate.put(e, PRESENT) != null;
+        return delegate.put(e, PRESENT) == null;
     }
 
     @Override