From 4dee383df9e4c59d6fbf85bd75effd06e696b90b Mon Sep 17 00:00:00 2001 From: Matt Garber Date: Tue, 15 Oct 2024 14:08:15 -0400 Subject: [PATCH] proper NULL casing --- src/handlers/dashboard/get_chart_data.py | 2 +- tests/dashboard/test_get_chart_data.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/handlers/dashboard/get_chart_data.py b/src/handlers/dashboard/get_chart_data.py index 9c66e10..4428839 100644 --- a/src/handlers/dashboard/get_chart_data.py +++ b/src/handlers/dashboard/get_chart_data.py @@ -64,7 +64,7 @@ def _build_query(query_params: dict, filters: list, path_params: dict) -> str: if len(columns) > 0: coalesce_str = ( f"WHERE COALESCE (cast({' AS VARCHAR), cast('.join(columns)} AS VARCHAR)) " - "IS NOT Null AND" + "IS NOT NULL AND" ) else: coalesce_str = "WHERE" diff --git a/tests/dashboard/test_get_chart_data.py b/tests/dashboard/test_get_chart_data.py index afe57a3..1cfe6aa 100644 --- a/tests/dashboard/test_get_chart_data.py +++ b/tests/dashboard/test_get_chart_data.py @@ -36,7 +36,7 @@ def mock_data_frame(filter_param): [], {"data_package_id": "test_study"}, f'SELECT gender, sum(cnt) as cnt FROM "{TEST_GLUE_DB}"."test_study" ' - "WHERE COALESCE (cast(race AS VARCHAR)) IS NOT Null AND gender IS NOT Null " + "WHERE COALESCE (cast(race AS VARCHAR)) IS NOT NULL AND gender IS NOT NULL " "GROUP BY gender ORDER BY gender", ), ( @@ -44,7 +44,7 @@ def mock_data_frame(filter_param): [], {"data_package_id": "test_study"}, f'SELECT race, gender, sum(cnt) as cnt FROM "{TEST_GLUE_DB}"."test_study" ' - "WHERE gender IS NOT Null " + "WHERE gender IS NOT NULL " "GROUP BY race, gender ORDER BY race, gender", ), ( @@ -52,7 +52,7 @@ def mock_data_frame(filter_param): ["gender:strEq:female"], {"data_package_id": "test_study"}, f'SELECT gender, sum(cnt) as cnt FROM "{TEST_GLUE_DB}"."test_study" ' - "WHERE COALESCE (cast(race AS VARCHAR)) IS NOT Null AND gender IS NOT Null " + "WHERE COALESCE (cast(race AS VARCHAR)) IS NOT Null AND gender IS NOT NULL " "AND gender LIKE 'female' " "GROUP BY gender ORDER BY gender", ), @@ -61,7 +61,7 @@ def mock_data_frame(filter_param): ["gender:strEq:female"], {"data_package_id": "test_study"}, f'SELECT race, gender, sum(cnt) as cnt FROM "{TEST_GLUE_DB}"."test_study" ' - "WHERE gender IS NOT Null " + "WHERE gender IS NOT NULL " "AND gender LIKE 'female' " "GROUP BY race, gender ORDER BY race, gender", ),