这是indexloc提供的服务,不要输入任何密码
Skip to content

Relax type requirements for primary uniqueness constraint #79

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 13, 2024

Conversation

dmoverton
Copy link
Contributor

@dmoverton dmoverton commented Jun 13, 2024

Don't require _id field to have type ObjectId when generate primary uniqueness constraint

Type

(Select only one. In case of multiple, choose the most appropriate)

  • highlight
  • enhancement
  • bugfix
  • behaviour-change
  • performance-enhancement
  • security-fix

@dmoverton dmoverton requested a review from hallettj June 13, 2024 06:37
@dmoverton dmoverton self-assigned this Jun 13, 2024
@dmoverton dmoverton requested review from hallettj and codedmart and removed request for hallettj June 13, 2024 06:38
schema::Type::Scalar(BsonScalarType::ObjectId) => Some(()),
_ => None,
}?;
let _id_field = object_type.fields.get("_id")?;
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this be validated to at least be a scalar type (and shouldn't it only be scalar types with equality?)?
What's the behaviour if the _id column is an object type? Does that break in v3-engine?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

MongoDB itself doesn't care. The _id can have any type and all types are comparable. However, I don't want to potentially break the engine, so I've modified it to only allow scalar types for which we define an equality operator in the capabilities.

Copy link
Collaborator

@hallettj hallettj left a comment

Choose a reason for hiding this comment

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

I didn't know that _id could be any type. But I guess if everything is schemaless it does make sense. Looks good!

@codedmart codedmart merged commit cd030f3 into main Jun 13, 2024
1 check passed
@codedmart codedmart deleted the dmoverton/relax_id_type branch June 13, 2024 18:53
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.

4 participants