@malloydata/malloy-tests 0.0.320 → 0.0.322
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.
package/package.json
CHANGED
|
@@ -21,14 +21,14 @@
|
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@jest/globals": "^29.4.3",
|
|
24
|
-
"@malloydata/db-bigquery": "0.0.
|
|
25
|
-
"@malloydata/db-duckdb": "0.0.
|
|
26
|
-
"@malloydata/db-postgres": "0.0.
|
|
27
|
-
"@malloydata/db-snowflake": "0.0.
|
|
28
|
-
"@malloydata/db-trino": "0.0.
|
|
29
|
-
"@malloydata/malloy": "0.0.
|
|
30
|
-
"@malloydata/malloy-tag": "0.0.
|
|
31
|
-
"@malloydata/render": "0.0.
|
|
24
|
+
"@malloydata/db-bigquery": "0.0.322",
|
|
25
|
+
"@malloydata/db-duckdb": "0.0.322",
|
|
26
|
+
"@malloydata/db-postgres": "0.0.322",
|
|
27
|
+
"@malloydata/db-snowflake": "0.0.322",
|
|
28
|
+
"@malloydata/db-trino": "0.0.322",
|
|
29
|
+
"@malloydata/malloy": "0.0.322",
|
|
30
|
+
"@malloydata/malloy-tag": "0.0.322",
|
|
31
|
+
"@malloydata/render": "0.0.322",
|
|
32
32
|
"events": "^3.3.0",
|
|
33
33
|
"jsdom": "^22.1.0",
|
|
34
34
|
"luxon": "^2.4.0",
|
|
@@ -38,5 +38,5 @@
|
|
|
38
38
|
"@types/jsdom": "^21.1.1",
|
|
39
39
|
"@types/luxon": "^2.4.0"
|
|
40
40
|
},
|
|
41
|
-
"version": "0.0.
|
|
41
|
+
"version": "0.0.322"
|
|
42
42
|
}
|
|
@@ -350,8 +350,23 @@ describe.each(runtimes.runtimeList)('filter expressions %s', (dbName, db) => {
|
|
|
350
350
|
});
|
|
351
351
|
});
|
|
352
352
|
|
|
353
|
-
const testBoolean = db.dialect.booleanType
|
|
353
|
+
const testBoolean = db.dialect.booleanType !== 'none';
|
|
354
354
|
describe('boolean filter expressions', () => {
|
|
355
|
+
/*
|
|
356
|
+
* We have the following truth table for boolean filters.
|
|
357
|
+
* The default malloy operations treat null as false. The '='
|
|
358
|
+
* variants exist for cases where that is not desired.
|
|
359
|
+
*
|
|
360
|
+
* filter expression | x=true | x=false | x=null
|
|
361
|
+
* true | T | F | F
|
|
362
|
+
* not true | F | T | T
|
|
363
|
+
* =true | T | F | NULL
|
|
364
|
+
* not =true | F | T | NULL
|
|
365
|
+
* false | F | T | T
|
|
366
|
+
* not false | T | F | F
|
|
367
|
+
* =false | F | T | NULL
|
|
368
|
+
* not =false | T | F | NULL
|
|
369
|
+
*/
|
|
355
370
|
const facts = db.loadModel(`
|
|
356
371
|
source: facts is ${dbName}.sql("""
|
|
357
372
|
SELECT true as ${q`b`}, 'true' as ${q`t`}
|
|
@@ -359,65 +374,111 @@ describe.each(runtimes.runtimeList)('filter expressions %s', (dbName, db) => {
|
|
|
359
374
|
UNION ALL SELECT NULL, 'null'
|
|
360
375
|
""")
|
|
361
376
|
`);
|
|
377
|
+
const factsSrc =
|
|
378
|
+
db.dialect.booleanType === 'supported'
|
|
379
|
+
? 'facts'
|
|
380
|
+
: 'facts extend {rename: sqlb is b; dimension: b is sqlb ? pick true when =true pick false when =false else null}';
|
|
362
381
|
test.when(testBoolean)('true', async () => {
|
|
363
382
|
await expect(`
|
|
364
|
-
run:
|
|
383
|
+
run: ${factsSrc} -> {
|
|
365
384
|
where: b ~ f'tRuE'
|
|
366
385
|
select: t; order_by: t asc
|
|
367
386
|
}`).malloyResultMatches(facts, [{t: 'true'}]);
|
|
368
387
|
});
|
|
388
|
+
test.when(testBoolean)('=true', async () => {
|
|
389
|
+
await expect(`
|
|
390
|
+
run: ${factsSrc} -> {
|
|
391
|
+
where: b ~ f'=TRUE'
|
|
392
|
+
select: t; order_by: t asc
|
|
393
|
+
}`).malloyResultMatches(facts, [{t: 'true'}]);
|
|
394
|
+
});
|
|
395
|
+
test.when(testBoolean)('not =true', async () => {
|
|
396
|
+
await expect(`
|
|
397
|
+
run: ${factsSrc} -> {
|
|
398
|
+
where: b ~ f'not =true'
|
|
399
|
+
select: t; order_by: t asc
|
|
400
|
+
}`).malloyResultMatches(facts, [{t: 'false'}]);
|
|
401
|
+
});
|
|
369
402
|
test.when(testBoolean)('false', async () => {
|
|
370
403
|
await expect(`
|
|
371
|
-
run:
|
|
404
|
+
run: ${factsSrc} -> {
|
|
372
405
|
where: b ~ f'FalSE'
|
|
373
406
|
select: t; order_by: t asc
|
|
374
407
|
}`).malloyResultMatches(facts, [{t: 'false'}, {t: 'null'}]);
|
|
375
408
|
});
|
|
376
409
|
test.when(testBoolean)('=false', async () => {
|
|
377
410
|
await expect(`
|
|
378
|
-
run:
|
|
411
|
+
run: ${factsSrc} -> {
|
|
379
412
|
where: b ~ f'=FALSE'
|
|
380
413
|
select: t; order_by: t asc
|
|
381
414
|
}`).malloyResultMatches(facts, [{t: 'false'}]);
|
|
382
415
|
});
|
|
383
416
|
test.when(testBoolean)('null', async () => {
|
|
384
417
|
await expect(`
|
|
385
|
-
run:
|
|
418
|
+
run: ${factsSrc} -> {
|
|
386
419
|
where: b ~ f'Null'
|
|
387
420
|
select: t; order_by: t asc
|
|
388
421
|
}`).malloyResultMatches(facts, [{t: 'null'}]);
|
|
389
422
|
});
|
|
390
423
|
test.when(testBoolean)('not null', async () => {
|
|
391
424
|
await expect(`
|
|
392
|
-
run:
|
|
425
|
+
run: ${factsSrc} -> {
|
|
393
426
|
where: b ~ f'nOt NuLL'
|
|
394
427
|
select: t; order_by: t asc
|
|
395
428
|
}`).malloyResultMatches(facts, [{t: 'false'}, {t: 'true'}]);
|
|
396
429
|
});
|
|
397
430
|
test.when(testBoolean)('not true', async () => {
|
|
398
431
|
await expect(`
|
|
399
|
-
run:
|
|
432
|
+
run: ${factsSrc} -> {
|
|
400
433
|
where: b ~ f'not true'
|
|
401
434
|
select: t; order_by: t asc
|
|
402
435
|
}`).malloyResultMatches(facts, [{t: 'false'}, {t: 'null'}]);
|
|
403
436
|
});
|
|
404
437
|
test.when(testBoolean)('not false', async () => {
|
|
405
438
|
await expect(`
|
|
406
|
-
run:
|
|
439
|
+
run: ${factsSrc} -> {
|
|
407
440
|
where: b ~ f'not false'
|
|
408
441
|
select: t; order_by: t asc
|
|
409
442
|
}`).malloyResultMatches(facts, [{t: 'true'}]);
|
|
410
443
|
});
|
|
411
444
|
test.when(testBoolean)('not =false', async () => {
|
|
412
445
|
await expect(`
|
|
413
|
-
run:
|
|
446
|
+
run: ${factsSrc} -> {
|
|
414
447
|
where: b ~ f'not =false'
|
|
415
448
|
select: t; order_by: t asc
|
|
416
|
-
}`).malloyResultMatches(facts, [{t: '
|
|
449
|
+
}`).malloyResultMatches(facts, [{t: 'true'}]);
|
|
450
|
+
});
|
|
451
|
+
test.when(testBoolean)('true (non-column)', async () => {
|
|
452
|
+
await expect(`
|
|
453
|
+
run: ${factsSrc} -> {
|
|
454
|
+
where: (pick b when 1=1 else false) ~ f'true'
|
|
455
|
+
select: t; order_by: t asc
|
|
456
|
+
}`).malloyResultMatches(facts, [{t: 'true'}]);
|
|
457
|
+
});
|
|
458
|
+
test.when(testBoolean)('not true (non-column)', async () => {
|
|
459
|
+
await expect(`
|
|
460
|
+
run: ${factsSrc} -> {
|
|
461
|
+
where: (pick b when 1=1 else false) ~ f'not true'
|
|
462
|
+
select: t; order_by: t asc
|
|
463
|
+
}`).malloyResultMatches(facts, [{t: 'false'}, {t: 'null'}]);
|
|
464
|
+
});
|
|
465
|
+
test.when(testBoolean)('false (non-column)', async () => {
|
|
466
|
+
await expect(`
|
|
467
|
+
run: ${factsSrc} -> {
|
|
468
|
+
where: (pick b when 1=1 else false) ~ f'false'
|
|
469
|
+
select: t; order_by: t asc
|
|
470
|
+
}`).malloyResultMatches(facts, [{t: 'false'}, {t: 'null'}]);
|
|
471
|
+
});
|
|
472
|
+
test.when(testBoolean)('not false (non-column)', async () => {
|
|
473
|
+
await expect(`
|
|
474
|
+
run: ${factsSrc} -> {
|
|
475
|
+
where: (pick b when 1=1 else false) ~ f'not false'
|
|
476
|
+
select: t; order_by: t asc
|
|
477
|
+
}`).malloyResultMatches(facts, [{t: 'true'}]);
|
|
417
478
|
});
|
|
418
479
|
test.when(testBoolean)('empty boolean filter', async () => {
|
|
419
480
|
await expect(`
|
|
420
|
-
run:
|
|
481
|
+
run: ${factsSrc} -> {
|
|
421
482
|
where: b ~ f''
|
|
422
483
|
select: t; order_by: t asc
|
|
423
484
|
}`).malloyResultMatches(facts, [
|