tailhook/serde-regex

`case_insensitive` flag falls off

ggevay opened this issue · 0 comments

One can build a regex with the case_insensitive flag like this:

let mut regex_builder = RegexBuilder::new("AAA");
regex_builder.case_insensitive(true);
let regex = regex_builder.build()?;

After roundtripping this regex through the serialize-deserialize functions derived by serde-regex, we lose the case_insensitive flag. This is because the derived serialize simply serializes the result of calling as_str() on the regex, which returns the original regex string ("AAA" in the above example), but doesn't include the flag.

I have a test here that is failing due to this bug: https://github.com/ggevay/materialize/blob/ilike-fixes-serde_derive-bug/src/repr/src/adt/regex.rs#L162