8000 Bitwise query on Int32 field throws server error · Issue #15170 · Automattic/mongoose · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Bitwise query on Int32 field throws server error #15170
@KeyboardRage

Description

@KeyboardRage

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

No one assigned

    Labels

    confirmed-bugWe've confirmed this is a bug in Mongoose and will fix it.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0