-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Closed
Labels
confirmed-bugWe've confirmed this is a bug in Mongoose and will fix it.We've confirmed this is a bug in Mongoose and will fix it.
Milestone
Description
Prerequisites
- I have written a descriptive issue title
- I have searched existing issues to ensure the bug has not already been reported
Mongoose version
8.9.3
Node.js version
22.11.0
MongoDB server version
7.0.15
Typescript version (if applicable)
5.7.2
Description
I previously used a plugin to support Int32 in schemas. With the latest version of Mongoose I could drop this plugin.
However, the queries that used to work now no longer works.
It seems to turn the query value from a number into null
.
The database then throws an error for invalid querying.
The error it throws:
MongoServerError: myField takes an Array, a number, or a BinData but received: $bitsAnySet: null
Steps to Reproduce
I can reproduce it with this setup.
const mongoose = require("mongoose");
mongoose.connect("mongodb://127.0.0.1:27017/test");
const Config = mongoose.model("Config", {
"myField": {
type: mongoose.SchemaTypes.Int32,
required: true,
},
});
const config = new Config({ myField: 3 });
config
.save()
.then(() => {
return Config.findOne({ myField: {$bitsAnySet: 1} });
})
.then(console.log);
Expected Behavior
The DB will find the record and return it.
Metadata
Metadata
Assignees
Labels
confirmed-bugWe've confirmed this is a bug in Mongoose and will fix it.We've confirmed this is a bug in Mongoose and will fix it.