Skip to content

Commit 56e753d

Browse files
COMPASS-5837 Go Export Improvements (#3103)
1 parent 131dbf1 commit 56e753d

File tree

6 files changed

+21
-15
lines changed

6 files changed

+21
-15
lines changed

packages/bson-transpilers/lib/symbol-table/javascripttogo.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/bson-transpilers/lib/symbol-table/pythontogo.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/bson-transpilers/lib/symbol-table/shelltogo.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/bson-transpilers/symbols/go/templates.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ Templates:
4747
DriverTemplate: &DriverTemplate !!js/function >
4848
(spec) => {
4949
const options = spec.options;
50+
const uri = spec.options.uri
5051
const filter = spec.filter || {};
5152
delete spec.options;
5253
delete spec.filter;
@@ -62,7 +63,7 @@ Templates:
6263
.concat('ctx := context.TODO()')
6364
.concat(this.declarations.length() > 0 ? `\n${this.declarations.toString()}\n` : '')
6465
.concat('// Set client options')
65-
.concat('clientOptions := options.Client().ApplyURI("mongodb://localhost:27017")')
66+
.concat(`clientOptions := options.Client().ApplyURI("${uri}")`)
6667
.concat('')
6768
.concat('// Connect to MongoDB')
6869
.concat('client, err := mongo.Connect(ctx, clientOptions)')
@@ -240,9 +241,9 @@ Templates:
240241
return `${indent}${arg},`;
241242
}
242243
NullTypeTemplate: &NullTypeTemplate !!js/function >
243-
() => 'primitive.Null'
244+
() => 'primitive.Null{}'
244245
UndefinedTypeTemplate: &UndefinedTypeTemplate !!js/function >
245-
() => 'primitive.Undefined'
246+
() => 'primitive.Undefined{}'
246247
ObjectTypeTemplate: &ObjectTypeTemplate !!js/function >
247248
(literal) => `bson.D{${literal}}`
248249
ObjectTypeArgsTemplate: &ObjectTypeArgsTemplate !!js/function >
@@ -934,6 +935,7 @@ Templates:
934935
(args) => {
935936
return [
936937
"go.mongodb.org/mongo-driver/mongo",
938+
"go.mongodb.org/mongo-driver/mongo/options",
937939
"context",
938940
"log"
939941
]

packages/bson-transpilers/test/yaml/driver-syntax.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ tests:
149149
"go.mongodb.org/mongo-driver/bson"
150150
"go.mongodb.org/mongo-driver/bson/primitive"
151151
"go.mongodb.org/mongo-driver/mongo"
152+
"go.mongodb.org/mongo-driver/mongo/options"
152153
"log"
153154
"strconv"
154155
)
@@ -287,6 +288,7 @@ tests:
287288
"context"
288289
"go.mongodb.org/mongo-driver/bson"
289290
"go.mongodb.org/mongo-driver/mongo"
291+
"go.mongodb.org/mongo-driver/mongo/options"
290292
"log"
291293
"strconv"
292294
)
@@ -539,6 +541,7 @@ tests:
539541
"go.mongodb.org/mongo-driver/bson"
540542
"go.mongodb.org/mongo-driver/bson/primitive"
541543
"go.mongodb.org/mongo-driver/mongo"
544+
"go.mongodb.org/mongo-driver/mongo/options"
542545
"log"
543546
"strconv"
544547
)
@@ -594,6 +597,7 @@ tests:
594597
"go.mongodb.org/mongo-driver/bson"
595598
"go.mongodb.org/mongo-driver/bson/primitive"
596599
"go.mongodb.org/mongo-driver/mongo"
600+
"go.mongodb.org/mongo-driver/mongo/options"
597601
"log"
598602
)
599603

packages/bson-transpilers/test/yaml/native.yaml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ tests:
462462
]
463463
go: |-
464464
bson.A{
465-
primitive.Undefined,
465+
primitive.Undefined{},
466466
"1",
467467
"2",
468468
}
@@ -483,7 +483,7 @@ tests:
483483
]
484484
go: |-
485485
bson.A{
486-
primitive.Undefined,
486+
primitive.Undefined{},
487487
}
488488
- input:
489489
javascript: "[,,]"
@@ -503,8 +503,8 @@ tests:
503503
]
504504
go: |-
505505
bson.A{
506-
primitive.Undefined,
507-
primitive.Undefined,
506+
primitive.Undefined{},
507+
primitive.Undefined{},
508508
}
509509
- input:
510510
javascript: "['1',,,,'2']"
@@ -528,9 +528,9 @@ tests:
528528
go: |-
529529
bson.A{
530530
"1",
531-
primitive.Undefined,
532-
primitive.Undefined,
533-
primitive.Undefined,
531+
primitive.Undefined{},
532+
primitive.Undefined{},
533+
primitive.Undefined{},
534534
"2",
535535
}
536536
Tuple:
@@ -1001,7 +1001,7 @@ tests:
10011001
object: 'null'
10021002
ruby: 'nil'
10031003
rust: 'Bson::Null'
1004-
go: primitive.Null
1004+
go: primitive.Null{}
10051005
- input:
10061006
javascript: 'undefined'
10071007
shell: 'undefined'
@@ -1014,7 +1014,7 @@ tests:
10141014
object: 'undefined'
10151015
ruby: 'nil'
10161016
rust: 'Bson::Undefined'
1017-
go: primitive.Undefined
1017+
go: primitive.Undefined{}
10181018
string_literals:
10191019
- input:
10201020
javascript: "'string'"

0 commit comments

Comments
 (0)