Skip to content

Commit c023d46

Browse files
committed
fixup: remove wrappable flag, skip async iter support for now, use fn instead of class
1 parent 209c9f5 commit c023d46

14 files changed

+139
-148
lines changed

packages/java-shell/src/main/kotlin/com/mongodb/mongosh/service/JavaServiceProvider.kt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@ internal class JavaServiceProvider(private var client: MongoClient?,
2222
@HostAccess.Export
2323
val platform = "JavaShell"
2424

25-
@JvmField
26-
@HostAccess.Export
27-
val deepInspectWrappable = false
28-
2925
@HostAccess.Export
3026
override fun runCommand(database: String, spec: Value): Value = promise {
3127
getDatabase(database, null).map { db ->
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{ "acknowledged": true, "insertedId": <ObjectID> }
2+
true
3+
[ { "_id": <ObjectID>, "a": 1, "objectId": <ObjectID>, "maxKey": {"$maxKey": 1}, "minKey": {"$minKey": 1}, "binData": {"$binary": {"base64": "MTIzNA==", "subType": "10"}}, "date": {"$date": {"$numberLong": "1355875200000"}}, "isoDate": {"$date": {"$numberLong": "1355875200000"}}, "numberInt": 24, "timestamp": {"$timestamp": {"t": 100, "i": 0}}, "undefined": null, "null": null, "uuid": <UUID> } ]
4+
{ "acknowledged": true, "insertedId": null }
5+
{ "acknowledged": true, "insertedId": {"$date": {"$numberLong": "1355875200000"}} }
6+
{ "acknowledged": true, "insertedId": <UUID> }
7+
{ "acknowledged": true, "insertedId": {"$maxKey": 1} }
8+
{ "acknowledged": true, "insertedId": 24 }
9+
{ "acknowledged": true, "insertedId": true }
10+
{ "acknowledged": true, "insertedId": "string key" }
11+
{ "acknowledged": true, "insertedId": {"$binary": {"base64": "MTIzNA==", "subType": "10"}} }
12+
{ "acknowledged": true, "insertedId": { "document": "key" } }

packages/service-provider-core/src/cursors.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export interface ServiceProviderBaseCursor<TSchema = Document> {
1515
next(): Promise<TSchema | null>;
1616
tryNext(): Promise<TSchema | null>;
1717
readonly closed: boolean;
18-
[Symbol.asyncIterator](): AsyncGenerator<TSchema, void, void>;
18+
[Symbol.asyncIterator]?(): AsyncGenerator<TSchema, void, void>;
1919
}
2020

2121
export interface ServiceProviderAbstractCursor<TSchema = Document>

packages/service-provider-core/src/service-provider.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,10 @@ export default interface ServiceProvider
1313
extends Readable,
1414
Writable,
1515
Closable,
16-
Admin {
17-
deepInspectWrappable: boolean;
18-
}
16+
Admin {}
1917

2018
export class ServiceProviderCore {
2119
public bsonLibrary: BSON;
22-
public deepInspectWrappable = true;
2320
constructor(bsonLibrary?: BSON) {
2421
if (bsonLibrary === undefined) {
2522
throw new MongoshInternalError('BSON Library is undefined.');

packages/shell-api/src/abstract-cursor.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,9 @@ export abstract class BaseCursor<
7676
}
7777

7878
async *[Symbol.asyncIterator]() {
79-
if (
80-
this._cursor[Symbol.asyncIterator] &&
81-
this._canDelegateIterationToUnderlyingCursor()
82-
) {
83-
yield* this._cursor;
79+
const baseIterator = this._cursor[Symbol.asyncIterator];
80+
if (baseIterator && this._canDelegateIterationToUnderlyingCursor()) {
81+
yield* baseIterator.call(this._cursor);
8482
return;
8583
}
8684

packages/shell-api/src/custom-inspect.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,16 @@ function customDocumentInspect(
2424

2525
function addInspectSymbol(obj: any) {
2626
if (!(obj as any)[customInspectSymbol]) {
27-
Object.defineProperty(obj, customInspectSymbol, {
28-
value: customDocumentInspect,
29-
enumerable: false,
30-
writable: true,
31-
configurable: true,
32-
});
27+
try {
28+
Object.defineProperty(obj, customInspectSymbol, {
29+
value: customDocumentInspect,
30+
enumerable: false,
31+
writable: true,
32+
configurable: true,
33+
});
34+
} catch {
35+
// Ignore, if the object is non-extensible we cannot do much about that
36+
}
3337
}
3438
}
3539

packages/shell-api/src/deep-inspect-aggregation-cursor-wrapper.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ export class DeepInspectAggregationCursorWrapper<TSchema = Document>
4747
return this._cursor.closed;
4848
}
4949

50-
async *[Symbol.asyncIterator]() {
50+
/*async *[Symbol.asyncIterator]() {
5151
yield* this._cursor;
5252
return;
53-
}
53+
}*/
5454
}
5555

5656
function forwardResultPromise<

packages/shell-api/src/deep-inspect-change-stream-wrapper.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ export class DeepInspectChangeStreamWrapper<TSchema = Document>
2929
return this._cursor.closed;
3030
}
3131

32-
async *[Symbol.asyncIterator]() {
32+
/*async *[Symbol.asyncIterator]() {
3333
yield* this._cursor;
3434
return;
35-
}
35+
}*/
3636
}
3737

3838
function forwardResultPromise<

packages/shell-api/src/deep-inspect-find-cursor-wrapper.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ export class DeepInspectFindCursorWrapper<TSchema = Document>
6161
return this._cursor.closed;
6262
}
6363

64-
async *[Symbol.asyncIterator]() {
64+
/*async *[Symbol.asyncIterator]() {
6565
yield* this._cursor;
6666
return;
67-
}
67+
}*/
6868
}
6969

7070
function forwardResultPromise<

packages/shell-api/src/deep-inspect-run-command-cursor-wrapper.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ export class DeepInspectRunCommandCursorWrapper<TSchema = Document>
3232
return this._cursor.closed;
3333
}
3434

35-
async *[Symbol.asyncIterator]() {
35+
/*async *[Symbol.asyncIterator]() {
3636
yield* this._cursor;
3737
return;
38-
}
38+
}*/
3939
}
4040

4141
function forwardResultPromise<

0 commit comments

Comments
 (0)