diff --git a/edc_qareports/utils.py b/edc_qareports/utils.py index 1f5adc4..f7f5d0e 100644 --- a/edc_qareports/utils.py +++ b/edc_qareports/utils.py @@ -10,6 +10,15 @@ def read_unmanaged_model_sql( ) -> str: if not fullpath: fullpath = Path(settings.BASE_DIR) / app_name / "models" / "unmanaged" / filename + + parsed_sql = [] with fullpath.open("r") as f: - sql = f.read() - return sql.replace("\n", " ") + for line in f: + line = line.split("#", maxsplit=1)[0] + line = line.split("-- ", maxsplit=1)[0] + line = line.replace("\n", "") + line = line.strip() + if line: + parsed_sql.append(line) + + return " ".join(parsed_sql)