1
0
Fork 0

fix result of AQL function `MIN` in case the first input element is (#9053)

`null`
This commit is contained in:
Jan 2019-05-21 15:43:33 +02:00 committed by GitHub
parent e8b7e1860a
commit 6cea7528fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 2 deletions

View File

@ -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`

View File

@ -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
////////////////////////////////////////////////////////////////////////////////