Skip to content
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

Setting Query.disableValidation() does not affect update operations #2229

Closed
zenbones opened this issue Jan 20, 2023 · 1 comment
Closed
Labels
Milestone

Comments

@zenbones
Copy link

If I want to disable validation on UpdateOperators.set(), there is no way to do so. The Query object holds enableValidation() and disableValidation() methods, but they have no effect on the validation of paths in update operators, and there is no longer any method which would have the desired effect, and therefore any object for which there is a custom codec is very unlikely to pass validation and can no longer be updated.

@zenbones zenbones added the bug label Jan 20, 2023
@zenbones
Copy link
Author

This error resolved. I think it may still be a bug, and I would be tempted to change UpdateBase line 76 to read something like...

        PathTarget pathTarget = new PathTarget(mapper, mapper.getEntityModel(type), update.field(), <query.isValidating() although query does not expose that curently, but maybe should>);

However, in the midst of trying that I found that JSON.parse() is deprecated, and BasicDBObject.parse() which is the recommended replacement throws an error if the value being parsed is not a document, which makes it useless. So I wrote my own converter from jackson's JsonNode directly to BsonValue, and when I UpdateOperators.set() with a BsonValue, I no longer get a validation error on the path. So my problem resolved and I'll close this issue, but... maybe UpdateBase should respect query.disableValidation()?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants