Skip to content

Commit cf7a041

Browse files
committed
refactor ResultWrapper constructor
1 parent 61d79a7 commit cf7a041

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

packages/cubejs-api-gateway/src/gateway.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1601,9 +1601,7 @@ class ApiGateway {
16011601
* @private
16021602
*/
16031603
private wrapAdapterQueryResultIfNeeded(res: any): ResultWrapper {
1604-
if (!(res.data instanceof ResultWrapper)) {
1605-
res.data = new ResultWrapper(null, res.data);
1606-
}
1604+
res.data = new ResultWrapper(res.data);
16071605

16081606
return res;
16091607
}

packages/cubejs-backend-native/js/ResultWrapper.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,26 @@ export class ResultWrapper extends BaseWrapper implements DataResult {
2424

2525
private readonly isNative: Boolean = false;
2626

27+
private readonly nativeReference: any;
28+
29+
private readonly jsResult: any = null;
30+
2731
private transformData: any;
2832

2933
private rootResultObject: any = {};
3034

31-
public constructor(private readonly nativeReference: any, private readonly jsResult: any = null) {
35+
public constructor(input: any) {
3236
super();
3337

34-
if (nativeReference) {
38+
if (input.isWrapper) {
39+
return input;
40+
}
41+
42+
if (Array.isArray(input)) {
43+
this.jsResult = input;
44+
} else {
3545
this.isNative = true;
46+
this.nativeReference = input;
3647
}
3748

3849
this.proxy = new Proxy(this, {

0 commit comments

Comments
 (0)