Skip to content

Conversation

@aditi-khare-mongoDB
Copy link
Contributor

@aditi-khare-mongoDB aditi-khare-mongoDB commented Nov 22, 2024

This PR follows the one opened on the mongodb fork, Val's initial round of feedback has been addressed.

Summary

Motivation
Support a 32-bit integer type in mongoose for compatibility with CSFLE/QE. The current Number schema type can result in either Int32, Int64, or Doubles that are inserted into the database using type inference but CSFLE and QE require exact BSON types in schemas.

Summary of Changes

  • Add SchemaType Int32, which has the following behavior:
    • its default cast method throws when provided a
      • a non-numeric string
      • a non-integer value
      • a NaN
      • a number beyond the bounds of INT32_MAX or INT32_MIN
    • it is queryable as $type: int or $type: number, but NOT $type: double
  • Add API Docs for new query option and new schema type

Example

const vehicleSchema = new Schema({ numberOfTires: mongoose.Int32 });

@aditi-khare-mongoDB
Copy link
Contributor Author

aditi-khare-mongoDB commented Nov 22, 2024

@vkarpov15

I've reopened the PR against the fork, here.

Here's a link to you open comment thread, so we can follow-up on it.

@aditi-khare-mongoDB aditi-khare-mongoDB marked this pull request as ready for review November 22, 2024 19:22
Copy link
Collaborator

@vkarpov15 vkarpov15 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. If it's ok with you, I will merge this into the 8.9 branch so we can merge it with the rest of the 8.9.0 release.

@aditi-khare-mongoDB
Copy link
Contributor Author

That works for me, thanks!

Copy link
Collaborator

@vkarpov15 vkarpov15 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I will merge this into 8.9 branch.

@vkarpov15 vkarpov15 changed the base branch from master to 8.9 December 5, 2024 22:43
@vkarpov15 vkarpov15 merged commit 6d8a0f2 into Automattic:8.9 Dec 5, 2024
43 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants