Closed mzikherman closed 7 years ago
1 Warning | |
---|---|
:warning: | There’re library changes, but not tests. That’s OK as long as you’re refactoring existing code. |
Generated by :no_entry_sign: danger
So does it not work for embedded?
or the older versions of Mongoid with Regexp::Raw
and why? The case implies that it doesn't, otherwise it would make things much simpler in code, no?
Yea, embedded?
docs are already loaded in memory and can just use Ruby's Regexp
. There's an open PR on Mongoid to bring that in to avoid the special handling for embedded docs.
The older versions of Mongoid bring in earlier versions of the driver (+ BSON gems) that don't include Regexp::Raw
, but also don't include the update that makes it not performant to use Regexp
on the server.
Thanks @mzikherman. Would you like to make a release? Happy to add you to maintainers + what's your rubygems email?
Yea, I'd love that! I am mzikherman@gmail.com on Rubygems
Added you here and Rubygems @mzikherman. Maybe you can also contribute a RELEASING doc ala https://github.com/mongoid/mongoid-compatibility/blob/master/RELEASING.md?
Btw, you're matt[at]artsymail.com
on rubygems...
This closes https://github.com/mongoid/mongoid-slug/issues/235
As discussed in that issue, and then continued in the discussion https://github.com/mongodb/bson-ruby/pull/71#issuecomment-290067567, it's better to use
Regexp::Raw
over Ruby'sRegexp
when querying the server. This allows prefixed expressions to use an index.However, when querying embedded documents that are already loaded in-memory, we should just be using Ruby's.
This isn't new functionality, so I didn't add any specs besides ensuring the current suite is passing.
However, as mentioned in https://github.com/mongoid/mongoid-slug/issues/235:
This seems like an awesome test! And one that is appropriate for this PR, as that's the crux of the change. I'll give that a shot, but wanted to open this PR in the meantime for feedback.