@cubejs-client/core 1.3.21 → 1.3.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,16 +1,19 @@
1
- export type SqlQueryTuple = [string, any[], any];
1
+ export type SqlQueryTuple = [string, any[], any?];
2
2
  export type SqlData = {
3
3
  aliasNameToMember: Record<string, string>;
4
4
  cacheKeyQueries: SqlQueryTuple[];
5
- dataSource: boolean;
5
+ dataSource: string;
6
6
  external: boolean;
7
7
  sql: SqlQueryTuple;
8
8
  preAggregations: any[];
9
9
  rollupMatchResults: any[];
10
10
  };
11
+ export type SqlQueryWrapper = {
12
+ sql: SqlData;
13
+ };
11
14
  export default class SqlQuery {
12
15
  private readonly sqlQuery;
13
- constructor(sqlQuery: SqlData);
16
+ constructor(sqlQuery: SqlQueryWrapper);
14
17
  rawQuery(): SqlData;
15
18
  sql(): string;
16
19
  }
@@ -1 +1 @@
1
- {"version":3,"file":"SqlQuery.d.ts","sourceRoot":"","sources":["../../src/SqlQuery.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG,CAAC,MAAM,EAAE,GAAG,EAAE,EAAE,GAAG,CAAC,CAAC;AAEjD,MAAM,MAAM,OAAO,GAAG;IACpB,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1C,eAAe,EAAE,aAAa,EAAE,CAAC;IACjC,UAAU,EAAE,OAAO,CAAC;IACpB,QAAQ,EAAE,OAAO,CAAC;IAClB,GAAG,EAAE,aAAa,CAAC;IACnB,eAAe,EAAE,GAAG,EAAE,CAAC;IACvB,kBAAkB,EAAE,GAAG,EAAE,CAAC;CAC3B,CAAC;AAEF,MAAM,CAAC,OAAO,OAAO,QAAQ;IAC3B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAU;gBAEhB,QAAQ,EAAE,OAAO;IAI7B,QAAQ,IAAI,OAAO;IAInB,GAAG,IAAI,MAAM;CAGrB"}
1
+ {"version":3,"file":"SqlQuery.d.ts","sourceRoot":"","sources":["../../src/SqlQuery.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG,CAAC,MAAM,EAAE,GAAG,EAAE,EAAE,GAAG,CAAC,CAAC,CAAC;AAElD,MAAM,MAAM,OAAO,GAAG;IACpB,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1C,eAAe,EAAE,aAAa,EAAE,CAAC;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,OAAO,CAAC;IAClB,GAAG,EAAE,aAAa,CAAC;IACnB,eAAe,EAAE,GAAG,EAAE,CAAC;IACvB,kBAAkB,EAAE,GAAG,EAAE,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAAE,GAAG,EAAE,OAAO,CAAA;CAAE,CAAC;AAE/C,MAAM,CAAC,OAAO,OAAO,QAAQ;IAC3B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAkB;gBAExB,QAAQ,EAAE,eAAe;IAIrC,QAAQ,IAAI,OAAO;IAInB,GAAG,IAAI,MAAM;CAGrB"}
@@ -3,7 +3,7 @@ export default class SqlQuery {
3
3
  this.sqlQuery = sqlQuery;
4
4
  }
5
5
  rawQuery() {
6
- return this.sqlQuery;
6
+ return this.sqlQuery.sql;
7
7
  }
8
8
  sql() {
9
9
  return this.rawQuery().sql[0];
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @license Apache-2.0
3
+ * @copyright Cube Dev, Inc.
4
+ * @fileoverview SqlQuery class unit tests.
5
+ */
6
+ export {};
7
+ //# sourceMappingURL=SqlQuery.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SqlQuery.test.d.ts","sourceRoot":"","sources":["../../test/SqlQuery.test.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * @license Apache-2.0
3
+ * @copyright Cube Dev, Inc.
4
+ * @fileoverview SqlQuery class unit tests.
5
+ */
6
+ /* globals describe,it,expect */
7
+ import SqlQuery from '../src/SqlQuery';
8
+ describe('SqlQuery', () => {
9
+ const mockCacheKeyQueriesTuple = [
10
+ 'SELECT FLOOR((-25200 + EXTRACT(EPOCH FROM NOW())) / 600) as refresh_key',
11
+ [],
12
+ {
13
+ external: false,
14
+ renewalThreshold: 60
15
+ }
16
+ ];
17
+ const mockSqlTuple = [
18
+ 'SELECT count(*) "base_orders__count" FROM base_orders WHERE base_orders.continent = ?',
19
+ ['Europe'],
20
+ ];
21
+ const mockSqlData = {
22
+ aliasNameToMember: { base_orders__count: 'base_orders.count' },
23
+ cacheKeyQueries: [mockCacheKeyQueriesTuple],
24
+ dataSource: 'default',
25
+ external: false,
26
+ sql: mockSqlTuple,
27
+ preAggregations: [],
28
+ rollupMatchResults: [],
29
+ };
30
+ const mockWrapper = {
31
+ sql: mockSqlData,
32
+ };
33
+ it('should construct without error', () => {
34
+ expect(() => new SqlQuery(mockWrapper)).not.toThrow();
35
+ });
36
+ it('rawQuery should return the original SqlData', () => {
37
+ const query = new SqlQuery(mockWrapper);
38
+ expect(query.rawQuery()).toEqual(mockSqlData);
39
+ });
40
+ it('sql should return the first element (SQL string) from the sql tuple', () => {
41
+ const query = new SqlQuery(mockWrapper);
42
+ expect(query.sql()).toBe('SELECT count(*) "base_orders__count" FROM base_orders WHERE base_orders.continent = ?');
43
+ });
44
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cubejs-client/core",
3
- "version": "1.3.21",
3
+ "version": "1.3.22",
4
4
  "engines": {},
5
5
  "repository": {
6
6
  "type": "git",
@@ -38,7 +38,7 @@
38
38
  ],
39
39
  "license": "MIT",
40
40
  "devDependencies": {
41
- "@cubejs-backend/linter": "1.3.21",
41
+ "@cubejs-backend/linter": "1.3.22",
42
42
  "@types/jest": "^29",
43
43
  "@types/moment-range": "^4.0.0",
44
44
  "@types/ramda": "^0.27.34",
@@ -50,5 +50,5 @@
50
50
  "eslintConfig": {
51
51
  "extends": "../cubejs-linter"
52
52
  },
53
- "gitHead": "f1621e4541f9dc546b3ca51b7babd288c2722106"
53
+ "gitHead": "71b2c1d2a9fb6a5218ea0c1b4dbcbc77463a402e"
54
54
  }