Skip to content

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

@zzrough

Description

@zzrough

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions