Skip to content

$regexp options not serialized #223

@zzrough

Description

@zzrough

hello,

using latest mongojack 4.5.0 (earlier versions also sports the issue), $regexp options do not seem to be serialized correctly.

I must check most thoroughly, but it's correct in Filters.$regexp processing but gets unserialized back by Mongojack and then serialized again and lost.

A simple program like this shows what's going on at the network level:

public class PatternDbTest {

    public static void main(String[] args) {
        MongoDatabase db = null;

        JacksonMongoCollection.builder()
                              .build(db, "products", TestProduct.class, UuidRepresentation.STANDARD)
                              .find(Filters.regex("name", "foo|BAR", "i"))
                              .first();
    }


    public static class TestProduct {
        @Id @ObjectId
        private String id;
        private String name;

        public String getId() { return id; }
        public void setId(String id) { this.id = id; }
        public String getName() { return name; }
        public void setName(String name) { this.name = name; }
    }
}

=> logging what's happening on the network I see that options are not properly serialized:

DEBUG [2022-07-11 09:33:37,367] org.mongodb.driver.protocol.command: Sending command '{"find": "products", "filter": {"name": {"$regularExpression": {"pattern": "foo|BAR", "options": ""}}}, .....

I just wanted to know if this rings a bell or not. I hope to find some time to investigate further.

best regards,
--Stéphane

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions