-
Notifications
You must be signed in to change notification settings - Fork 1
reverse Timestamp() param order COMPASS-5733 #109
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,25 +26,24 @@ | |
"bson": "^4.2.3" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.14.3", | ||
"@babel/core": "^7.16.0", | ||
"@babel/plugin-proposal-class-properties": "^7.13.0", | ||
"@babel/plugin-proposal-object-rest-spread": "^7.11.0", | ||
"@babel/preset-env": "^7.13.12", | ||
"@babel/preset-typescript": "^7.13.0", | ||
"@babel/preset-env": "^7.15.6", | ||
"@babel/preset-typescript": "^7.15.6", | ||
"@preconstruct/cli": "^2.1.0", | ||
"@types/bson": "^4.0.3", | ||
"@types/estree": "^0.0.41", | ||
"@types/jest": "^26.0.21", | ||
"benchmark": "^2.1.4", | ||
"bson": "^4.2.3", | ||
"bson": "^4.6.3", | ||
"husky": ">=5", | ||
"jest": "^26.6.3", | ||
"lint-staged": ">=11", | ||
"mongodb-query-parser": "2.1.1", | ||
"np": "^7.4.0", | ||
"prettier": "^1.19.1", | ||
"ts-jest": "^26.5.4", | ||
"typescript": "^3.9.9" | ||
"typescript": "^4.3.5" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Had to bump typescript because bson became typescript and it was still expecting a @types/bson which kept giving me this error:
|
||
}, | ||
"preconstruct": { | ||
"umdName": "EJSONShellParser", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,6 +64,12 @@ const SCOPE: { [x: string]: Function } = { | |
return new (bson as any).BSONSymbol(i); | ||
}, | ||
Timestamp: function(low: any, high: any) { | ||
if (typeof low === 'number' && typeof high === 'number') { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Only nit is possibly we need to change the parameters from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I went back and forth on that. My current thinking (and really this is still very easy to change) is that the function gets the 32-bit words in that order. BUT Timestamp is overloaded and can take either one or two params. So in a sense it is just an args array that we have to inspect and either pass through unchanged or do something specific with in this one case. Which is kinda the long way of saying I can't think of anything better than maybe There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe that's what we should do? I agree that it probably doesn't matter much either way, we're just passing stuff in and praying it's valid anyway. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @addaleax what do you think? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No strong preferences, I think it’s fine to keep them as they are or to switch them, the important thing is that it’s visible to readers that something is going on here and I think that is being achieved :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Was about to suggest calling the params |
||
// https://www.mongodb.com/docs/manual/reference/bson-types/#timestamps | ||
// reverse the order to match the legacy shell | ||
return new bson.Timestamp({ t: low, i: high }); | ||
} | ||
|
||
return new bson.Timestamp(low, high); | ||
}, | ||
ISODate: function(...args: any[]) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,7 +48,9 @@ it('should accept a complex query', function() { | |
ObjectID: ObjectID("5e159ba7eac34211f2252aaa"), | ||
ObjectId: ObjectId("5e159ba7eac34211f2252aaa"), | ||
Symbol: Symbol('symbol'), | ||
Timestamp: Timestamp(123, 456), | ||
Timestamp: Timestamp(100, 0), | ||
Timestamp_object: Timestamp({ t: 1, i: 2 }), | ||
Timestamp_long: Timestamp(new Long(1, 2)), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just trying to come up with a test case that shows that Timestamp()'s params aren't always two numbers. |
||
ISODate: ISODate("2020-01-01 12:00:00"), | ||
Date: Date("2020-01-01 12:00:00") | ||
}`) | ||
|
@@ -80,7 +82,9 @@ it('should accept a complex query', function() { | |
ObjectID: new bson.ObjectID('5e159ba7eac34211f2252aaa'), | ||
ObjectId: new bson.ObjectId('5e159ba7eac34211f2252aaa'), | ||
Symbol: new (bson as any).BSONSymbol('symbol'), | ||
Timestamp: new bson.Timestamp(123, 456), | ||
Timestamp: new bson.Timestamp({ t: 100, i: 0 }), | ||
Timestamp_object: new bson.Timestamp({ t: 1, i: 2 }), | ||
Timestamp_long: new bson.Timestamp(bson.Long.fromNumber(8589934593)), | ||
ISODate: new Date('2020-01-01 12:00:00'), | ||
Date: new Date('2020-01-01 12:00:00'), | ||
}); | ||
|
@@ -95,7 +99,7 @@ it('should support binary operators (like plus / minus)', function() { | |
}`) | ||
).toEqual({ | ||
_id: new bson.ObjectId('5e159ba7eac34211f2252aaa'), | ||
created: new bson.Timestamp(20, 10), | ||
created: new bson.Timestamp(10, 20), | ||
filter: { year: { $gte: 2020 } }, | ||
}); | ||
}); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had to bump bson so we can gain support for {t, i } in tests. See mongodb/js-bson#449