by warpech · 4y ago · 0 comments
"As of Mongoid 7.1, logical operators (and, or, nor and not) have been changed to have the the same semantics as those of ActiveRecord. To obtain the semantics of or as it behaved in Mongoid 7.0 and earlier, use any_of which is described below."
Is it just me or is this one of the most terrible breaking changes in a popular, official library ever?
[1] https://docs.mongodb.com/mongoid/current/tutorials/mongoid-q...
They knew they were making a breaking change, documented it, and didn't increment a major version number. That breaks the entire point of semver.
Also, this is generating SQL ffs. Like how more nasty of a breaking change could you make in terms of potential impact to live apps that upgrade? The experience in the post is a perfect example of how badly this can go wrong.
If you update your dependencies and ship it based on version numbers alone, you can’t blame the maintainers
OP did not say changes should not be tested.
> If you update your dependencies and ship it based on version numbers alone, you can’t blame the maintainers
OP did not if you update your dependencies and ship it based on version numbers alone you can blame the maintainers.
Even a minor bug fix in a library can expose a critical bug in your own code.
The isolated point the commenter was making is that a dangerous breaking change was introduced without the versioning reflecting that fact.
Both these things can be true, and any failure on the part of the startup does not remove the failure of the package versioning. These things are not contradictory so yes, you can blame the maintainers (also) as the guilt or otherwise of the startup does not alter the original versioning fail.
So in order to update a dependency you must first write a test that fail on current version and is green on updated version.
Breaking change: In Mongoid 7.1, when condition methods are invoked on a Criteria object, they always add new conditions to the existing conditions in the Criteria object. Previously new conditions could have replaced existing conditions in some circumstances.
Ironically they also have a breaking change in 7.1.1, so they just don't give a fuck at all.
That said I would normally read 'User.where({id: id}).or({condition1},{condition2})' as 'User where id=id or condition1 or condition2' and not 'User where id=id and (condition1 or condition2)'. Though I could probably get used to either, after all you've also got languages like Lisp where 'or' isn't an infix operator either.
And doing something with any one of the results when you only expect one result to exist is just bad practice.
The problem is, once you deploy to production you have (hopefully) tested this case and rely on the actual implementation.
But this kind of behavior change at best should have introduced different API.
Crazy to think that someone remotely can alter your query ANDs to ORs. That may very well destroy your database data and a whole lot of pain to rollback.
After such a problem, I would roll back and never ever update this dependency again.
How people blog and how they feel aren't always the same thing. Professionals tend to be a lot more tactful in public communication.