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

$regexp options not serialized #223

Closed
zzrough opened this issue Jul 11, 2022 · 4 comments
Closed

$regexp options not serialized #223

zzrough opened this issue Jul 11, 2022 · 4 comments
Milestone

Comments

@zzrough
Copy link

zzrough commented Jul 11, 2022

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

@rlodge
Copy link
Contributor

rlodge commented Jul 15, 2022

It's not something I'm familiar with, but all the testing seems to be done with Pattern.compile() instead of with strings.

@rlodge
Copy link
Contributor

rlodge commented Jul 15, 2022

In the short term, if you use Pattern.compile("(?i)foo|BAR"), the tests indicate that it should work.

@rlodge
Copy link
Contributor

rlodge commented Jul 15, 2022

I have published a 4.5.1-SNAPSHOT version that I think fixes this. Please let me know if it works for you.

@rlodge rlodge added this to the 4.5.1 milestone Jul 22, 2022
@rlodge
Copy link
Contributor

rlodge commented Jul 22, 2022

Fix deployed 4.5.1 and 4.7.0

@rlodge rlodge closed this as completed Jul 22, 2022
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