Skip to content

Commit

Permalink
refactor ResultWrapper constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
KSDaemon committed Jan 10, 2025
1 parent 810808a commit 5612755
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
4 changes: 1 addition & 3 deletions packages/cubejs-api-gateway/src/gateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1581,9 +1581,7 @@ class ApiGateway {
* @private
*/
private wrapAdapterQueryResultIfNeeded(res: any): ResultWrapper {
if (!(res.data instanceof ResultWrapper)) {
res.data = new ResultWrapper(null, res.data);
}
res.data = new ResultWrapper(res.data);

return res;
}
Expand Down
15 changes: 13 additions & 2 deletions packages/cubejs-backend-native/js/ResultWrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,26 @@ export class ResultWrapper extends BaseWrapper implements DataResult {

private readonly isNative: Boolean = false;

private readonly nativeReference: any;

private readonly jsResult: any = null;

private transformData: any;

private rootResultObject: any = {};

public constructor(private readonly nativeReference: any, private readonly jsResult: any = null) {
public constructor(input: any) {
super();

if (nativeReference) {
if (input.isWrapper) {
return input;
}

if (Array.isArray(input)) {
this.jsResult = input;
} else {
this.isNative = true;
this.nativeReference = input;
}

this.proxy = new Proxy(this, {
Expand Down

0 comments on commit 5612755

Please sign in to comment.