Skip to content

Commit b5b221a

Browse files
jocelynz-stripeKSDaemon
authored andcommitted
move test case
1 parent 455f549 commit b5b221a

File tree

2 files changed

+51
-44
lines changed

2 files changed

+51
-44
lines changed

packages/cubejs-schema-compiler/test/integration/postgres/sql-generation.test.ts

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -860,25 +860,6 @@ SELECT 1 AS revenue, cast('2024-01-01' AS timestamp) as time UNION ALL
860860
includes: ['count']
861861
}]
862862
})
863-
864-
cube('boolean_dimension', {
865-
sql: \`
866-
SELECT
867-
'true' AS dim
868-
\`,
869-
dimensions: {
870-
dim: {
871-
sql: \`dim\`,
872-
type: 'boolean',
873-
primaryKey: true
874-
}
875-
},
876-
measures: {
877-
count: {
878-
type: 'count',
879-
}
880-
}
881-
});
882863
`);
883864

884865
it('simple join', async () => {
@@ -2014,31 +1995,6 @@ SELECT 1 AS revenue, cast('2024-01-01' AS timestamp) as time UNION ALL
20141995
expect(query.buildSqlAndParams()[0]).toMatch(/OFFSET (\d)\s+LIMIT (\d)/);
20151996
});
20161997

2017-
it('bool param cast (PrestoQuery)', async () => {
2018-
await compiler.compile();
2019-
2020-
const query = new PrestodbQuery({ joinGraph, cubeEvaluator, compiler }, {
2021-
measures: [
2022-
'boolean_dimension.count',
2023-
],
2024-
timeDimensions: [{
2025-
dimension: 'boolean_dimension.dim',
2026-
}],
2027-
filters: [
2028-
{
2029-
member: 'boolean_dimension.dim',
2030-
operator: 'equals',
2031-
values: ['true'],
2032-
},
2033-
],
2034-
});
2035-
2036-
const queryAndParams = query.buildSqlAndParams();
2037-
console.log(queryAndParams);
2038-
2039-
expect(queryAndParams[0]).toContain('"boolean_dimension".dim = CAST(? AS BOOLEAN)');
2040-
});
2041-
20421998
it('calculated join', async () => {
20431999
await compiler.compile();
20442000

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/* eslint-disable no-restricted-syntax */
2+
import { PrestodbQuery } from '../../src/adapter/PrestodbQuery';
3+
import { prepareJsCompiler } from './PrepareCompiler';
4+
5+
describe('PrestodbQuery', () => {
6+
const { compiler, joinGraph, cubeEvaluator } = prepareJsCompiler(`
7+
cube('boolean_dimension', {
8+
sql: \`
9+
SELECT
10+
'true' AS dim
11+
\`,
12+
dimensions: {
13+
dim: {
14+
sql: \`dim\`,
15+
type: 'boolean',
16+
primaryKey: true
17+
}
18+
},
19+
measures: {
20+
count: {
21+
type: 'count',
22+
}
23+
}
24+
});
25+
`);
26+
27+
it('bool param cast (PrestoQuery)', async () => {
28+
await compiler.compile();
29+
30+
const query = new PrestodbQuery({ joinGraph, cubeEvaluator, compiler }, {
31+
measures: [
32+
'boolean_dimension.count',
33+
],
34+
timeDimensions: [{
35+
dimension: 'boolean_dimension.dim',
36+
}],
37+
filters: [
38+
{
39+
member: 'boolean_dimension.dim',
40+
operator: 'equals',
41+
values: ['true'],
42+
},
43+
],
44+
});
45+
46+
const queryAndParams = query.buildSqlAndParams();
47+
console.log(queryAndParams);
48+
49+
expect(queryAndParams[0]).toContain('"boolean_dimension".dim = CAST(? AS BOOLEAN)');
50+
});
51+
});

0 commit comments

Comments
 (0)