mongodb version
- Dominant language
- JavaScript
- Stars
- 1.8k
- Forks
- 180
- PR merge metrics
- No merged PRs in 30d
Description
seems like the driver version is stuck at a fairly low version. when using https://mongoplayground.net/
with the following as the data and query:
```
[
{
"paymentId": "1234",
"balances": {
"balance": "1000"
},
grants: [
{
status: "completed"
},
{
status: "active"
}
]
},
{
"paymentId": "1234",
"balances": {
"balance": "2000"
},
grants: [
{
status: "completed"
}
]
}
]
```
```
db.collection.aggregate([
{
$match: {
paymentId: {
$nin: [
"",
null
]
}
}
},
{
$project: {
_id: 0,
balance: "$balances.balance",
created: {
$dateToString: {
format: "%Y-%m-%d",
date: "$_id"
}
},
virtual: {
$gt: [
{
$size: {
$filter: {
input: {
$ifNull: [
"$grants",
[]
]
},
as: "grant",
cond: {
$ne: [
"$$grant.status",
"completed"
]
}
}
}
},
0
]
},
funded: {
$cond: {
if: {
$ne: [
"$balances.confirmed",
"0"
]
},
then: 1,
else: 0
}
}
}
},
{
$group: {
_id: "$created",
balance: {
$push: "$balance"
},
virtual: {
$sum: {
$cond: {
if: "$virtual",
then: 1,
else: 0
}
}
},
funded: {
$sum: "$funded"
},
wallets: {
$sum: 1
}
}
},
{
"$project": {
_id: 1,
wallets: 1,
virtual: 1,
funded: 1,
balance: {
$reduce: {
"input": "$balance",
"initialValue": 0,
"in": {
$sum: [
"$$value",
{
$convert: {
input: "$$this",
to: "int",
onError: "parseInt($this)"
}
}
]
}
}
}
}
},
{
$project: {
created: "$_id",
wallets: 1,
balance: 1,
virtual: 1,
funded: 1,
_id: 0
}
}
])
```
the query passes. but when using monk in it's latest version the query produces a different result.
```
// right
[
{
"balance": 3001,
"created": "2018-02-26",
"funded": 2,
"virtual": 1,
"wallets": 2
}
]
```
```
// wrong
[
{
"balance": 0,
"created": "2018-02-26",
"funded": 2,
"virtual": 1,
"wallets": 2
}
]
```
same things happen when using `toInt` and `toLong` instead of `convert`, except the query just fails
Contributor guide
No contributing guide indexed for this repository
Research direction
Reproduce the aggregation with the data and query in the issue using mongoplayground.net and the latest Monk version, then compare the results. Investigate the MongoDB driver version used by Monk and verify the behavior of $convert, toInt, and toLong; done means the query returns the expected balance of 3001 rather than 0.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, mongodb
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100