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

Filters.regexp not working but DBQuery.regexp is fine #220

Closed
zzrough opened this issue Oct 13, 2021 · 0 comments
Closed

Filters.regexp not working but DBQuery.regexp is fine #220

zzrough opened this issue Oct 13, 2021 · 0 comments

Comments

@zzrough
Copy link

zzrough commented Oct 13, 2021

I've recently migrated from 2.10.0 to 4.2.1 and removed all deprecated code.

I'm using JacksonMongoCollection and almost everything works great except a corner case: for Map-based embedded docs: Filters.regexp does not work where DBQuery.regexp is fine.

  • Filters.regexp("field", Pattern.compile("^[0-9]")) works fine (serialized to a regexp doc)
  • Filters.regexp("field.subfield", Pattern.compile("^[0-9]")) is NOT working (serialized to a string through a ToStringSerializer) (field being a generic Map<String,Object> in java)

Using a custom ObjectMapper and a custom PatternSerializer just inheriting EmbeddedObjectSerializer fixes the issue, but this should not fail to begin with.

I've prepared a PR for this, but I'm unsure if it's the best way to fix it, but serializing and deserializing in DocumentSerializationUtilsImpl#serializeFilter seems to lose information as I get at runtime a MapSerializer then ToStringSerializer and the db query sent to the server does not work.

zzrough pushed a commit to zzrough/mongojack that referenced this issue Oct 13, 2021
For Map-based embedded docs, Filters.regexp is not working where
DBQuery.regexp is being fine.

* Filters.regexp("field", Pattern.compile("^[0-9]")) is fine
  (serialized to a regexp doc)
* Filters.regexp("field.subfield", Pattern.compile("^[0-9]")) is NOT working
  (serialized to a string) (field being a generic Map<String,Object> in java)

At runtime DocumentSerializationUtilsImpl#serializeFilter loses the Pattern
type information because we get a MapSerializer then a ToStringSerializer and
the db query sent to the server is thus wrong.
@rlodge rlodge closed this as completed Oct 19, 2021
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

2 participants