mirror of https://gitee.com/bigwinds/arangodb
fix result of AQL function `MIN` in case the first input element is (#9053)
`null`
This commit is contained in:
parent
e8b7e1860a
commit
6cea7528fb
|
@ -171,7 +171,7 @@ struct AggregatorMin final : public Aggregator {
|
|||
void reset() override { value.erase(); }
|
||||
|
||||
void reduce(AqlValue const& cmpValue) override {
|
||||
if (value.isEmpty() || (!cmpValue.isNull(true) &&
|
||||
if (!cmpValue.isNull(true) && (value.isEmpty() ||
|
||||
AqlValue::Compare(trx, value, cmpValue, true) > 0)) {
|
||||
// the value `null` itself will not be used in MIN() to compare lower than
|
||||
// e.g. value `false`
|
||||
|
|
|
@ -903,6 +903,19 @@ function optimizerAggregateTestSuite () {
|
|||
assertEqual(results.json[0], AQL_EXECUTE("RETURN MIN([ null, null, null, null ])").json[0]);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test min
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testMinNotOnlyNullButStartsWithNull : function () {
|
||||
var query = "FOR i IN [ null, null, null, null, 35 ] COLLECT AGGREGATE m = MIN(i) RETURN m";
|
||||
|
||||
var results = AQL_EXECUTE(query);
|
||||
assertEqual(1, results.json.length);
|
||||
assertEqual(35, results.json[0]);
|
||||
assertEqual(results.json[0], AQL_EXECUTE("RETURN MIN([ null, null, null, null, 35 ])").json[0]);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test min
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
Loading…
Reference in New Issue