Skip to content

Commit 538629c

Browse files
fix failing tests
1 parent 021f84b commit 538629c

File tree

7 files changed

+13
-9
lines changed

7 files changed

+13
-9
lines changed

docs/schematypes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ const schema = new Schema({
6969
mixed: Schema.Types.Mixed,
7070
_someId: Schema.Types.ObjectId,
7171
decimal: Schema.Types.Decimal128,
72-
32bitInt: Schema.Types.Int32,
72+
int32bit: Schema.Types.Int32,
7373
array: [],
7474
ofString: [String],
7575
ofNumber: [Number],

lib/cast/int32.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ module.exports = function castInt32(val) {
2727

2828
const _val = Number(val);
2929

30-
if (_val !== _val | 0 && _val > INT32_MIN && _val < INT32_MAX) {
30+
if (_val === (_val | 0) && _val > INT32_MIN && _val < INT32_MAX) {
3131
return _val;
3232
}
3333
assert.ok(false);

lib/drivers/browser/int32.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44

55
'use strict';
66

7-
module.exports = require('bson').Int32;
7+
module.exports = require('bson').Int32;

lib/schema.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1494,8 +1494,6 @@ Schema.prototype.interpretAsType = function(path, obj, options) {
14941494
name = 'ObjectId';
14951495
} else if (type === Types.Decimal128) {
14961496
name = 'Decimal128';
1497-
} else if (type === Types.Int32) {
1498-
name = 'Int32';
14991497
} else {
15001498
name = type == null ? '' + type : type.toString();
15011499
}
@@ -2850,7 +2848,7 @@ module.exports = exports = Schema;
28502848
* - [Mixed](https://mongoosejs.com/docs/schematypes.html#mixed)
28512849
* - [UUID](https://mongoosejs.com/docs/schematypes.html#uuid)
28522850
* - [BigInt](https://mongoosejs.com/docs/schematypes.html#bigint)
2853-
* - Int32
2851+
* - [Int32](https://mongoosejs.com/docs/schematypes.html#int32)
28542852
*
28552853
* Using this exposed access to the `Mixed` SchemaType, we can use them in our schema.
28562854
*

lib/types/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ exports.Embedded = require('./arraySubdocument');
1414
exports.DocumentArray = require('./documentArray');
1515
exports.Decimal128 = require('./decimal128');
1616
exports.ObjectId = require('./objectid');
17-
exports.ObjectId = require('./int32');
17+
exports.Int32 = require('./int32');
1818

1919
exports.Map = require('./map');
2020

lib/types/int32.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010

1111
'use strict';
1212

13-
module.exports = require('bson').Int32;
13+
module.exports = require('bson').Int32;

test/types/schema.test.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,9 @@ export function autoTypedSchema() {
425425
decimal1?: Types.Decimal128 | null;
426426
decimal2?: Types.Decimal128 | null;
427427
decimal3?: Types.Decimal128 | null;
428+
int32_1?: Types.Int32 | null;
429+
int32_2?: Types.Int32 | null;
430+
int32_3?: Types.Int32 | null;
428431
};
429432

430433
const TestSchema = new Schema({
@@ -471,7 +474,10 @@ export function autoTypedSchema() {
471474
array8: { type: [String], default: () => undefined },
472475
decimal1: Schema.Types.Decimal128,
473476
decimal2: 'Decimal128',
474-
decimal3: 'decimal128'
477+
decimal3: 'decimal128',
478+
int32_1: Schema.Types.Int32,
479+
int32_2: 'Int32',
480+
int32_3: 'int32'
475481
});
476482

477483
type InferredTestSchemaType = InferSchemaType<typeof TestSchema>;

0 commit comments

Comments
 (0)