Skip to content

Commit

Permalink
fix(client-core): castNumerics option for CubeApi (#8186)
Browse files Browse the repository at this point in the history
  • Loading branch information
vasilev-alex committed Apr 24, 2024
1 parent 35bb1d4 commit 6ff2208
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/cubejs-client-core/index.d.ts
Expand Up @@ -80,6 +80,7 @@ declare module '@cubejs-client/core' {
credentials?: 'omit' | 'same-origin' | 'include';
parseDateMeasures?: boolean;
resType?: 'default' | 'compact';
castNumerics?: boolean;
};

export type LoadMethodOptions = {
Expand Down
11 changes: 11 additions & 0 deletions packages/cubejs-client-core/src/index.js
Expand Up @@ -56,6 +56,7 @@ class CubeApi {
});
this.pollInterval = options.pollInterval || 5;
this.parseDateMeasures = options.parseDateMeasures;
this.castNumerics = typeof options.castNumerics === 'boolean' ? options.castNumerics : false;

this.updateAuthorizationPromise = null;
}
Expand Down Expand Up @@ -308,6 +309,11 @@ class CubeApi {
}

load(query, options, callback, responseFormat = ResultType.DEFAULT) {
options = {
castNumerics: this.castNumerics,
...options
};

if (responseFormat === ResultType.COMPACT) {
if (Array.isArray(query)) {
query = query.map((q) => this.patchQueryInternal(q, ResultType.COMPACT));
Expand All @@ -327,6 +333,11 @@ class CubeApi {
}

subscribe(query, options, callback, responseFormat = ResultType.DEFAULT) {
options = {
castNumerics: this.castNumerics,
...options
};

if (responseFormat === ResultType.COMPACT) {
if (Array.isArray(query)) {
query = query.map((q) => this.patchQueryInternal(q, ResultType.COMPACT));
Expand Down

0 comments on commit 6ff2208

Please sign in to comment.