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

Mongoid/Mongodb issues after upgrade to 4.3 #1411

Open
dotsi opened this issue Sep 12, 2023 · 0 comments
Open

Mongoid/Mongodb issues after upgrade to 4.3 #1411

dotsi opened this issue Sep 12, 2023 · 0 comments

Comments

@dotsi
Copy link

dotsi commented Sep 12, 2023

After upgrading to the latest engine version 4.3 we are having issues pushing some resources from wagon to engine.
I traced the issue to some breaking changes in how Mongoid handles operator combinations since 7.1:
https://www.mongodb.com/docs/mongoid/7.5/reference/queries/#operator-combinations

This named scope produces a different result on the 4.3 version of the engine:
scope :by_id_or_slug, ->(id_or_slug) { all.or({ _id: id_or_slug }, { slug: id_or_slug }) }

Test from the Rails console:
irb(main):028:0> site.sections.by_id_or_slug("hero").size=> 47

irb(main):029:0> site.sections.where(slug: "hero").or(_id: "hero").size=> 1

irb(main):030:0> site.sections.by_id_or_slug("hero").selector=> {"site_id"=>BSON::ObjectId('5ebfc39e232fb906a3dfc34b'), "$or"=>[{"site_id"=>BSON::ObjectId('5ebfc39e232fb906a3dfc34b')}, {"_id"=>"hero"}, {"slug"=>"hero"}]}

irb(main):031:0> site.sections.where(slug: "hero").or(_id: "hero").selector=> {"$or"=>[{"site_id"=>BSON::ObjectId('5ebfc39e232fb906a3dfc34b'), "slug"=>"hero"}, {"_id"=>"hero"}]}

The previous engine versions produce a selector like this:
2.5.1 :010 > silte.sections.by_id_or_slug("image_bg").size => 1
2.5.1 :011 > silte.sections.by_id_or_slug("image_bg").selector => {"site_id"=>BSON::ObjectId('5c82be9824d35f685b3b632f'), "$or"=>[{"_id"=>"image_bg"}, {"slug"=>"image_bg"}]}

This is the one place I found the issue. Probably there are other places.
Right now the only solution I see is to downgrade back to 4.1.1 until this is patched.

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

No branches or pull requests

1 participant