-
Notifications
You must be signed in to change notification settings - Fork 165
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
Fix #222: Mongo::Error::OperationFailure: E11000 duplicate key error index. #225
Conversation
Could you also add in a check to see if |
Good point @Dan-Nolan, that seems to work, see specs in 218d257. |
Sweet! Thanks for checking that out! |
The bigger question is, should we allow I think the logic to generate a fallback slug should be handled by the implementer on a case-by-case basis. I'm not convinced that using the model name as a default fallback is an elegant solution. |
@johnnyshields You think that |
@dblock sparse indexes will ignore documents which do not have the https://docs.mongodb.com/manual/core/index-sparse/ As of MongoDB 3.2 there's a better option called "partial indexes" (sparse index on steroids) where you can exclude values |
@johnnyshields I updated this PR. The problem is that we default |
@dblock this needs to be tested. my understanding is that sparse indexes consider "nil" (null) as a value if it's explicitly set in the db, so be careful. I've filed an issue with Mongoid that they need a way to distinguish between nil and unset. |
@johnnyshields: This is tested here, note that I am creating an index in |
I hear you @johnnyshields on 3.2.0, we could default to The code in Mongoid doesn't set the value to |
b46d738
to
67433a2
Compare
Ok, I am pretty happy with what's in this PR. @johnnyshields: do you think I am doing it all wrong or can I merge this? @Dan-Nolan: the implementation has changed and since we last spoke, check this out. @BorisBresciani you opened #222, please check this out. |
@dblock looks fine to me. |
@dblock Looks great to me; very well documented too! Handling fallback slugs in a case-by-case basis makes sense, and in our case, we ended up not allowing values to resolve to empty stringex urls. It was bad data for us anyhow. |
FYI was released in 5.3.0 |
This is a proposed fix for #222. The problem is that we try to create records with a blank indexed field that generates blank slugs, which causes the unique index to break. We remove the default value of
[]
and store anil
slug that works with asparse: true
index.I'd love a code review from @johnnyshields or @digitalplaywright please.