Skip to content

Commit

Permalink
DCV-1705 add extra_config_path modification timestamp to avoid uninte…
Browse files Browse the repository at this point in the history
…nded caching
  • Loading branch information
BAntonellini committed Sep 20, 2023
1 parent 8242cc4 commit 03afb4e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/dbt_core_interface/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -6215,6 +6215,11 @@ def lint_sql(
if request.query.get("extra_config_path")
else None
),
config_last_modification=(
request.query.get("config_last_modification")
if request.query.get("config_last_modification")
else None
),
)
result = temp_result["violations"] if temp_result is not None else []
except Exception as lint_err:
Expand Down
6 changes: 6 additions & 0 deletions src/dbt_core_interface/sqlfluff_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,18 @@ def get_linter(
):
"""Get linter."""
from sqlfluff.cli.commands import get_linter_and_formatter

return get_linter_and_formatter(config, stream)[0]


# Cache config to prevent wasted frames
@lru_cache(maxsize=50)
def get_config(
dbt_project_root: Path,
extra_config_path: Optional[Path] = None,
ignore_local_config: bool = False,
require_dialect: bool = True,
config_last_modification: Optional[str] = None,
**kwargs,
) -> FluffConfig:
"""Similar to the get_config() function used by SQLFluff command line.
Expand Down Expand Up @@ -65,6 +68,7 @@ def lint_command(
sql: Union[Path, str],
extra_config_path: Optional[Path] = None,
ignore_local_config: bool = False,
config_last_modification: Optional[str] = None,
) -> Optional[Dict]:
"""Lint specified file or SQL string.
Expand All @@ -86,6 +90,7 @@ def lint_command(
project_root,
extra_config_path,
ignore_local_config,
config_last_modification,
require_dialect=False,
nocolor=True,
)
Expand All @@ -112,6 +117,7 @@ def test_lint_command():
"""
logging.basicConfig(level=logging.DEBUG)
from dbt_core_interface.project import DbtProjectContainer

dbt = DbtProjectContainer()
dbt.add_project(
name_override="dbt_project",
Expand Down

0 comments on commit 03afb4e

Please sign in to comment.