From d48e814f287316c973cdbe26bbe4a51be1731d47 Mon Sep 17 00:00:00 2001 From: z3z1ma Date: Tue, 18 Apr 2023 12:15:51 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20account=20for=20contextless=20re?= =?UTF-8?q?ndering=20in=20dbt=20codebase?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .changes/0.5.1.md | 3 +++ CHANGELOG.md | 4 ++++ dbt_feature_flags/patch.py | 8 ++++---- pyproject.toml | 2 +- 4 files changed, 12 insertions(+), 5 deletions(-) create mode 100644 .changes/0.5.1.md diff --git a/.changes/0.5.1.md b/.changes/0.5.1.md new file mode 100644 index 0000000..d0ae6ce --- /dev/null +++ b/.changes/0.5.1.md @@ -0,0 +1,3 @@ +## 0.5.1 - 2023-04-18 +### Fixed +* Account for "contextless" rendering in dbt codebase by supplying a default implementation for each variation matching var diff --git a/CHANGELOG.md b/CHANGELOG.md index c9f91b7..8a1ccab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html), and is generated by [Changie](https://github.com/miniscruff/changie). +## 0.5.1 - 2023-04-18 +### Fixed +* Account for "contextless" rendering in dbt codebase by supplying a default implementation for each variation matching var + ## 0.5.0 - 2023-04-17 ### Changed * Translate all feature flag calls to var calls in the event no provider is used. This allows users to manage feature flags locally and seamlessly transition between that model and a dedicated provider. diff --git a/dbt_feature_flags/patch.py b/dbt_feature_flags/patch.py index 6327d84..0e1537a 100644 --- a/dbt_feature_flags/patch.py +++ b/dbt_feature_flags/patch.py @@ -79,10 +79,10 @@ def _wrapped( native: bool = False, ): if client is _MOCK_CLIENT: - ctx["feature_flag"] = ctx["var"] - ctx["feature_flag_str"] = ctx["var"] - ctx["feature_flag_num"] = ctx["var"] - ctx["feature_flag_json"] = ctx["var"] + ctx["feature_flag"] = ctx.get("var", lambda _, default=False: default) + ctx["feature_flag_str"] = ctx.get("var", lambda _, default="": default) + ctx["feature_flag_num"] = ctx.get("var", lambda _, default=0: default) + ctx["feature_flag_json"] = ctx.get("var", lambda _, default={}: default) else: ctx["feature_flag"] = client.bool_variation ctx["feature_flag_str"] = client.string_variation diff --git a/pyproject.toml b/pyproject.toml index a1823ac..c635d51 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "dbt-feature-flags" -version = "0.5.0" +version = "0.5.1" description = "Use feature flags in dbt models" authors = ["z3z1ma "] include = ["zzz_dbt_feature_flags.pth"]