Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test framework lookup_<table> function translates NULL value filter to "= NULL" instead of "IS NULL" #242

Closed
alepev opened this issue Jun 17, 2020 · 2 comments
Labels

Comments

@alepev
Copy link

alepev commented Jun 17, 2020

Given these test cases:

  1. expect_person(person_id = 203)
  2. expect_death(person_id = 203, death_date = NULL)
  3. expect_person( lookup_death('person_id', death_date = NULL) )

I get the following results:

  1. PASS (the person with id 203 exists in the Person table)
  2. PASS (the same person, with no death date, also exists in the Death table)
  3. FAIL! somehow, the lookup function finds no person_id with a missing death date in the Death table, even though the previous test found it just fine.

I took a closer look at the automatically generated SQL queries, and discovered that in test case 2, death_date = NULL gets correctly translated into IS NULL;
however, in test case 3 it becomes = NULL, which fails.

Here are the test case 2 & 3 SQL queries in full:

INSERT INTO omopcdm.test_results SELECT 203 AS id, 'Missing death date' AS description, 'Expect death' AS test, CASE WHEN (SELECT COUNT(*) FROM omopcdm.death WHERE person_id = '203' AND death_date IS NULL) = 0 THEN 'FAIL' ELSE 'PASS' END AS status;

INSERT INTO omopcdm.test_results SELECT 203 AS id, 'Missing death date' AS description, 'Expect person' AS test, CASE WHEN (SELECT COUNT(*) FROM omopcdm.person WHERE person_id = (SELECT person_id FROM omopcdm.death WHERE death_date = NULL)) = 0 THEN 'FAIL' ELSE 'PASS' END AS status;

@alepev
Copy link
Author

alepev commented Jun 17, 2020

NOTE: the test framework was created with RiaH v0.9.0 and the target CDM version is 5.3.1.

@MaximMoinat
Copy link
Collaborator

That reminds me: the exported TestFramework R script should have a comment with the RiaH version used to create it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants