@@ -315,40 +315,38 @@ describe('SQL Generation', function test() {
315
315
});
316
316
` ) ;
317
317
318
-
319
- it ( 'filter with operator OR' , ( ) => {
320
- const result = compiler . compile ( ) . then ( ( ) => {
321
- const query = new PostgresQuery ( { joinGraph, cubeEvaluator, compiler } , {
322
- measures : [
323
- 'visitor_checkins.google_sourced_checkins'
324
- ] ,
325
- timeDimensions : [ ] ,
326
- filters : [
327
- {
328
- or : [
329
- { dimension : 'cards.id' , operator : 'equals' , values : [ '3' ] } ,
330
- { dimension : 'cards.id' , operator : 'equals' , values : [ '1' ] }
331
- ]
332
- } ,
333
- ] ,
334
- timezone : 'America/Los_Angeles'
335
- } ) ;
336
-
337
- console . log ( query . buildSqlAndParams ( ) ) ;
318
+ it ( 'filter with operator OR' , async ( ) => {
319
+ await compiler . compile ( ) ;
338
320
339
- return dbRunner . testQuery ( query . buildSqlAndParams ( ) ) . then ( res => {
340
- console . log ( JSON . stringify ( res ) ) ;
341
- res . should . be . deepEqual (
342
- [ { 'visitor_checkins__google_sourced_checkins' : '1' } ]
343
- ) ;
344
- } ) ;
321
+ const query = new PostgresQuery ( { joinGraph, cubeEvaluator, compiler } , {
322
+ measures : [
323
+ 'visitor_checkins.google_sourced_checkins'
324
+ ] ,
325
+ timeDimensions : [ ] ,
326
+ filters : [
327
+ {
328
+ or : [
329
+ { dimension : 'cards.id' , operator : 'equals' , values : [ '3' ] } ,
330
+ { dimension : 'cards.id' , operator : 'equals' , values : [ '1' ] }
331
+ ]
332
+ } ,
333
+ ] ,
334
+ timezone : 'America/Los_Angeles'
345
335
} ) ;
346
336
347
- return result ;
337
+ console . log ( query . buildSqlAndParams ( ) ) ;
338
+
339
+ return dbRunner . testQuery ( query . buildSqlAndParams ( ) ) . then ( res => {
340
+ console . log ( JSON . stringify ( res ) ) ;
341
+ res . should . be . deepEqual (
342
+ [ { 'visitor_checkins__google_sourced_checkins' : '1' } ]
343
+ ) ;
344
+ } ) ;
348
345
} ) ;
349
-
350
346
351
- it ( 'having and where filter in same operator OR' , ( ) => compiler . compile ( ) . then ( ( ) => {
347
+ it ( 'having and where filter in same operator OR' , async ( ) => {
348
+ await compiler . compile ( ) ;
349
+
352
350
try {
353
351
const query = new PostgresQuery ( { joinGraph, cubeEvaluator, compiler } , {
354
352
'measures' : [
@@ -381,15 +379,17 @@ describe('SQL Generation', function test() {
381
379
'visitors.source'
382
380
]
383
381
} ) ;
384
-
382
+
385
383
throw new Error ( ) ;
386
384
} catch ( error ) {
387
385
// You cannot use dimension and measure in same condition
388
386
error . should . be . instanceof ( UserError ) ;
389
387
}
390
- } ) ) ;
391
-
392
- it ( 'having filter with operator OR' , ( ) => compiler . compile ( ) . then ( ( ) => {
388
+ } ) ;
389
+
390
+ it ( 'having filter with operator OR' , async ( ) => {
391
+ await compiler . compile ( ) ;
392
+
393
393
const query = new PostgresQuery ( { joinGraph, cubeEvaluator, compiler } , {
394
394
measures : [
395
395
'visitors.visitor_count' ,
@@ -438,10 +438,11 @@ describe('SQL Generation', function test() {
438
438
} ]
439
439
) ;
440
440
} ) ;
441
- } ) ) ;
441
+ } ) ;
442
442
443
+ it ( 'having filter with operators OR & AND' , async ( ) => {
444
+ await compiler . compile ( ) ;
443
445
444
- it ( 'having filter with operators OR & AND' , ( ) => compiler . compile ( ) . then ( ( ) => {
445
446
const query = new PostgresQuery ( { joinGraph, cubeEvaluator, compiler } , {
446
447
measures : [
447
448
'visitors.visitor_count' ,
@@ -508,9 +509,11 @@ describe('SQL Generation', function test() {
508
509
} ]
509
510
) ;
510
511
} ) ;
511
- } ) ) ;
512
+ } ) ;
513
+
514
+ it ( 'having filter with operators OR & AND (with filter based on measures not from select part clause)' , async ( ) => {
515
+ await compiler . compile ( ) ;
512
516
513
- it ( 'having filter with operators OR & AND (with filter based on measures not from select part clause)' , ( ) => compiler . compile ( ) . then ( ( ) => {
514
517
const query = new PostgresQuery ( { joinGraph, cubeEvaluator, compiler } , {
515
518
measures : [
516
519
'visitors.visitor_count' ,
@@ -577,9 +580,11 @@ describe('SQL Generation', function test() {
577
580
} ]
578
581
) ;
579
582
} ) ;
580
- } ) ) ;
583
+ } ) ;
584
+
585
+ it ( 'where filter with operators OR & AND' , async ( ) => {
586
+ await compiler . compile ( ) ;
581
587
582
- it ( 'where filter with operators OR & AND' , ( ) => compiler . compile ( ) . then ( ( ) => {
583
588
const query = new PostgresQuery ( { joinGraph, cubeEvaluator, compiler } , {
584
589
measures : [
585
590
'visitors.visitor_count'
@@ -643,9 +648,11 @@ describe('SQL Generation', function test() {
643
648
} ]
644
649
) ;
645
650
} ) ;
646
- } ) ) ;
651
+ } ) ;
652
+
653
+ it ( 'where filter with operators OR & AND (with filter based on dimensions not from select part clause)' , async ( ) => {
654
+ await compiler . compile ( ) ;
647
655
648
- it ( 'where filter with operators OR & AND (with filter based on dimensions not from select part clause)' , ( ) => compiler . compile ( ) . then ( ( ) => {
649
656
const query = new PostgresQuery ( { joinGraph, cubeEvaluator, compiler } , {
650
657
measures : [
651
658
'visitors.visitor_count'
@@ -706,9 +713,11 @@ describe('SQL Generation', function test() {
706
713
} ]
707
714
) ;
708
715
} ) ;
709
- } ) ) ;
716
+ } ) ;
717
+
718
+ it ( 'where filter with only one argument' , async ( ) => {
719
+ await compiler . compile ( ) ;
710
720
711
- it ( 'where filter with only one argument' , ( ) => compiler . compile ( ) . then ( ( ) => {
712
721
const query = new PostgresQuery ( { joinGraph, cubeEvaluator, compiler } , {
713
722
measures : [
714
723
'visitors.visitor_count'
@@ -766,9 +775,11 @@ describe('SQL Generation', function test() {
766
775
} ]
767
776
) ;
768
777
} ) ;
769
- } ) ) ;
778
+ } ) ;
779
+
780
+ it ( 'where filter without arguments' , async ( ) => {
781
+ await compiler . compile ( ) ;
770
782
771
- it ( 'where filter without arguments' , ( ) => compiler . compile ( ) . then ( ( ) => {
772
783
const query = new PostgresQuery ( { joinGraph, cubeEvaluator, compiler } , {
773
784
measures : [
774
785
'visitors.visitor_count'
@@ -812,9 +823,11 @@ describe('SQL Generation', function test() {
812
823
console . log ( JSON . stringify ( res ) ) ;
813
824
res . should . be . deepEqual ( [ { 'visitors__source' : 'some' , 'visitors__visitor_count' : '2' } ] ) ;
814
825
} ) ;
815
- } ) ) ;
826
+ } ) ;
827
+
828
+ it ( 'where filter without any arguments' , async ( ) => {
829
+ await compiler . compile ( ) ;
816
830
817
- it ( 'where filter without any arguments' , ( ) => compiler . compile ( ) . then ( ( ) => {
818
831
const query = new PostgresQuery ( { joinGraph, cubeEvaluator, compiler } , {
819
832
measures : [
820
833
'visitors.visitor_count'
@@ -858,8 +871,11 @@ describe('SQL Generation', function test() {
858
871
]
859
872
) ;
860
873
} ) ;
861
- } ) ) ;
862
- it ( 'where filter with incorrect one arguments' , ( ) => compiler . compile ( ) . then ( ( ) => {
874
+ } ) ;
875
+
876
+ it ( 'where filter with incorrect one arguments' , async ( ) => {
877
+ await compiler . compile ( ) ;
878
+
863
879
try {
864
880
const query = new PostgresQuery ( { joinGraph, cubeEvaluator, compiler } , {
865
881
measures : [
@@ -874,28 +890,28 @@ describe('SQL Generation', function test() {
874
890
{
875
891
and : [
876
892
{ and : [
877
- {
878
- or : [
879
- {
880
- and : [
881
- {
882
- measure : 'visitors.source' ,
883
- operator : 'equals' ,
884
- values : [ 'some' ]
885
- }
886
- ]
887
- } ,
888
- {
889
- and : [
890
- {
891
- dimension : 'visitors_source' ,
892
- operator : 'equals' ,
893
- values : [ 'google' ]
894
- }
895
- ]
896
- }
897
- ]
898
- } ]
893
+ {
894
+ or : [
895
+ {
896
+ and : [
897
+ {
898
+ measure : 'visitors.source' ,
899
+ operator : 'equals' ,
900
+ values : [ 'some' ]
901
+ }
902
+ ]
903
+ } ,
904
+ {
905
+ and : [
906
+ {
907
+ dimension : 'visitors_source' ,
908
+ operator : 'equals' ,
909
+ values : [ 'google' ]
910
+ }
911
+ ]
912
+ }
913
+ ]
914
+ } ]
899
915
} ]
900
916
} ] ,
901
917
order : [ {
@@ -907,7 +923,7 @@ describe('SQL Generation', function test() {
907
923
} catch ( error ) {
908
924
error . should . be . instanceof ( UserError ) ;
909
925
}
910
- } ) ) ;
926
+ } ) ;
911
927
912
928
// end of tests
913
929
} ) ;
0 commit comments