Skip to content

Commit 7e5a481

Browse files
Merge branch 'v1' into GODRIVER-3567-v1
2 parents 0121771 + ba0613a commit 7e5a481

File tree

3 files changed

+52
-5
lines changed

3 files changed

+52
-5
lines changed

.github/workflows/merge-up.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Merge up
2+
3+
on:
4+
push:
5+
branches:
6+
- release/*.*
7+
- v*
8+
9+
permissions:
10+
id-token: write
11+
contents: write
12+
pull-requests: write
13+
14+
jobs:
15+
merge-up:
16+
name: Create merge up pull request
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- uses: mongodb-labs/drivers-github-tools/secure-checkout@v2
21+
with:
22+
app_id: ${{ vars.PR_APP_ID }}
23+
private_key: ${{ secrets.PR_APP_PRIVATE_KEY }}
24+
# Make sure to include fetch-depth 0 so all branches are fetched, not
25+
# just the current one
26+
fetch-depth: 0
27+
28+
- name: Create pull request
29+
id: create-pull-request
30+
uses: alcaeus/automatic-merge-up-action@main
31+
with:
32+
ref: ${{ github.ref_name }}
33+
branchNamePattern: 'release/<major>.<minor>'
34+
devBranchNamePattern: 'v<major>'
35+
fallbackBranch: 'master'
36+
enableAutoMerge: true

bson/bson_test.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"go.mongodb.org/mongo-driver/bson/bsoncodec"
2020
"go.mongodb.org/mongo-driver/bson/bsonoptions"
2121
"go.mongodb.org/mongo-driver/bson/bsontype"
22+
"go.mongodb.org/mongo-driver/bson/primitive"
2223
"go.mongodb.org/mongo-driver/internal/assert"
2324
"go.mongodb.org/mongo-driver/x/bsonx/bsoncore"
2425
)
@@ -226,11 +227,20 @@ func TestMapCodec(t *testing.T) {
226227
}
227228

228229
func TestExtJSONEscapeKey(t *testing.T) {
229-
doc := D{{Key: "\\usb#", Value: int32(1)}}
230+
doc := D{
231+
{
232+
Key: "\\usb#",
233+
Value: int32(1),
234+
},
235+
{
236+
Key: "regex",
237+
Value: primitive.Regex{Pattern: "ab\\\\\\\"ab", Options: "\""},
238+
},
239+
}
230240
b, err := MarshalExtJSON(&doc, false, false)
231241
noerr(t, err)
232242

233-
want := "{\"\\\\usb#\":1}"
243+
want := `{"\\usb#":1,"regex":{"$regularExpression":{"pattern":"ab\\\\\\\"ab","options":"\""}}}`
234244
if diff := cmp.Diff(want, string(b)); diff != "" {
235245
t.Errorf("Marshaled documents do not match. got %v, want %v", string(b), want)
236246
}

bson/bsonrw/extjson_writer.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -468,12 +468,13 @@ func (ejvw *extJSONValueWriter) WriteRegex(pattern string, options string) error
468468
return err
469469
}
470470

471+
options = sortStringAlphebeticAscending(options)
471472
var buf bytes.Buffer
472473
buf.WriteString(`{"$regularExpression":{"pattern":`)
473474
writeStringWithEscapes(pattern, &buf, ejvw.escapeHTML)
474-
buf.WriteString(`,"options":"`)
475-
buf.WriteString(sortStringAlphebeticAscending(options))
476-
buf.WriteString(`"}},`)
475+
buf.WriteString(`,"options":`)
476+
writeStringWithEscapes(options, &buf, ejvw.escapeHTML)
477+
buf.WriteString(`}},`)
477478

478479
ejvw.buf = append(ejvw.buf, buf.Bytes()...)
479480

0 commit comments

Comments
 (0)