diff --git a/cumulus_library/log_utils.py b/cumulus_library/log_utils.py index 2a04be8c..32e32032 100644 --- a/cumulus_library/log_utils.py +++ b/cumulus_library/log_utils.py @@ -38,7 +38,7 @@ def log_transaction( __version__, status.value, base_utils.get_utc_datetime(), - message if message else None, + message or None, ] ], ) diff --git a/cumulus_library/template_sql/insert_into.sql.jinja b/cumulus_library/template_sql/insert_into.sql.jinja index aca08fef..214bf302 100644 --- a/cumulus_library/template_sql/insert_into.sql.jinja +++ b/cumulus_library/template_sql/insert_into.sql.jinja @@ -13,7 +13,7 @@ VALUES {%- if table_cols[loop.index0] in type_casts.keys() -%} {{ type_casts[table_cols[loop.index0]] }} '{{ field }}' {%- elif not field -%} - NULL + CAST(NULL AS VARCHAR) {%- else -%} '{{ field }}' {%- endif -%} diff --git a/tests/test_cli.py b/tests/test_cli.py index 14866f2e..984b80a4 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -85,12 +85,12 @@ def test_cli_early_exit(args): ( ["build", "-t", "study_python_valid", "--builder", "module2"], does_not_raise(), - "study_python_valid__table_2", + "study_python_valid__count_table", ), ( ["build", "-t", "study_bad_manifest"], pytest.raises(errors.StudyManifestParsingError), - "study_python_valid__table_2", + "study_python_valid__count_table", ), (["build", "-t", "wrong"], pytest.raises(SystemExit), None), ( @@ -225,6 +225,8 @@ def test_generate_md(mock_path, tmp_path): pathlib.Path(__file__).resolve().parent / "test_data/study_python_valid_generated.md" ) + with open(test_file) as f: + print(f.read()) assert filecmp.cmp(test_file, ref_file, shallow=True) diff --git a/tests/test_data/study_python_valid/manifest.toml b/tests/test_data/study_python_valid/manifest.toml index d201182b..6509804b 100644 --- a/tests/test_data/study_python_valid/manifest.toml +++ b/tests/test_data/study_python_valid/manifest.toml @@ -2,3 +2,8 @@ study_prefix = "study_python_valid" [table_builder_config] file_names = ["module1.py", "module1.py", "module2.py"] + +[export_config] +export_list = [ + "study_python_valid__count_table" +] \ No newline at end of file diff --git a/tests/test_data/study_python_valid/module2.py b/tests/test_data/study_python_valid/module2.py index 9ba693c1..a0b8854a 100644 --- a/tests/test_data/study_python_valid/module2.py +++ b/tests/test_data/study_python_valid/module2.py @@ -6,5 +6,5 @@ class ModuleTwoRunner(BaseTableBuilder): def prepare_queries(self, cursor: object, schema: str, *args, **kwargs): self.queries.append( - "CREATE TABLE IF NOT EXISTS study_python_valid__table_2 (test int);" + "CREATE TABLE IF NOT EXISTS study_python_valid__count_table (test int);" ) diff --git a/tests/test_data/study_python_valid_generated.md b/tests/test_data/study_python_valid_generated.md index 2d197279..9335c71b 100644 --- a/tests/test_data/study_python_valid_generated.md +++ b/tests/test_data/study_python_valid_generated.md @@ -1,3 +1,12 @@ +## study_python_valid count tables + +### study_python_valid__count_table + +|Column| Type |Description| +|------|-------|-----------| +|test |INTEGER| | + + ## study_python_valid base tables ### study_python_valid__lib_transactions @@ -18,10 +27,3 @@ |test |INTEGER| | -### study_python_valid__table_2 - -|Column| Type |Description| -|------|-------|-----------| -|test |INTEGER| | - -