|
26 | 26 |
|
27 | 27 | import org.bson.BsonBinary;
|
28 | 28 | import org.bson.BsonBinarySubType;
|
| 29 | +import org.bson.BsonRegularExpression; |
29 | 30 | import org.bson.Document;
|
30 | 31 | import org.bson.codecs.DecoderContext;
|
31 | 32 | import org.junit.jupiter.api.Test;
|
32 | 33 |
|
33 | 34 | import org.springframework.data.expression.ValueExpressionParser;
|
34 |
| -import org.springframework.data.mapping.model.ValueExpressionEvaluator; |
35 | 35 | import org.springframework.data.spel.EvaluationContextProvider;
|
36 | 36 | import org.springframework.data.spel.ExpressionDependencies;
|
37 | 37 | import org.springframework.expression.EvaluationContext;
|
@@ -84,6 +84,26 @@ void bindQuotedIntegerValue() {
|
84 | 84 | assertThat(target).isEqualTo(new Document("lastname", "100"));
|
85 | 85 | }
|
86 | 86 |
|
| 87 | + @Test // GH-4806 |
| 88 | + void regexConsidersOptions() { |
| 89 | + |
| 90 | + Document target = parse("{ 'c': /^true$/i }"); |
| 91 | + |
| 92 | + BsonRegularExpression pattern = target.get("c", BsonRegularExpression.class); |
| 93 | + assertThat(pattern.getPattern()).isEqualTo("^true$"); |
| 94 | + assertThat(pattern.getOptions()).isEqualTo("i"); |
| 95 | + } |
| 96 | + |
| 97 | + @Test // GH-4806 |
| 98 | + void regexConsidersBindValueWithOptions() { |
| 99 | + |
| 100 | + Document target = parse("{ 'c': /^?0$/i }", "foo"); |
| 101 | + |
| 102 | + BsonRegularExpression pattern = target.get("c", BsonRegularExpression.class); |
| 103 | + assertThat(pattern.getPattern()).isEqualTo("^foo$"); |
| 104 | + assertThat(pattern.getOptions()).isEqualTo("i"); |
| 105 | + } |
| 106 | + |
87 | 107 | @Test
|
88 | 108 | void bindValueToRegex() {
|
89 | 109 |
|
|
0 commit comments