-
Type: Bug
-
Resolution: Fixed
-
Priority: Minor - P4
-
Affects Version/s: None
-
Component/s: Aggregation Framework
-
Fully Compatible
-
ALL
-
v3.6, v3.4, v3.2
$pow has issues where a NumberLong base of -1 is used with a NumberLong exponent of a negative odd value.
For example:
Unable to find source-code formatter for language: javascript. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
MongoDB Enterprise > db.v.aggregate({$project: {'a': { $pow: [ NumberLong(-1), NumberLong(-5) ] }, 'b' : { $pow: [ -1, NumberLong(-3) ] } } }) { "_id" : ObjectId("5a689c791de68d211f6234d6"), "a" : NumberLong(1), "b" : -1 }
Removing the NumberLong from either argument causes the right answer. It seems to be related purely to the return type being NumberLong, though I can confirm there are no issues with positive odd exponents.
- links to