Skip to content

Commit

Permalink
behavior flags take the default value when the project file is not lo…
Browse files Browse the repository at this point in the history
…aded
  • Loading branch information
mikealfare committed Oct 24, 2024
1 parent d4309ea commit 105db3a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
6 changes: 6 additions & 0 deletions .changes/unreleased/Fixes-20241024-154518.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Fixes
body: Always make behavior flags available for evaluation
time: 2024-10-24T15:45:18.114936-04:00
custom:
Author: mikealfare
Issue: "338"
14 changes: 7 additions & 7 deletions dbt/adapters/base/impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,13 +300,13 @@ def behavior(self) -> Behavior:
@behavior.setter # type: ignore
def behavior(self, flags: List[BehaviorFlag]) -> None:
flags.extend(self._behavior_flags)
try:
# we don't always get project flags, for example during `dbt debug`
self._behavior = Behavior(flags, self.config.flags)
except AttributeError:
# in that case, load behavior flags with their default values to avoid compilation errors
# this mimics not loading a project file, or not specifying flags in a project file
self._behavior = Behavior(flags, {})

# we don't always get project flags, for example, the project file is not loaded during `dbt debug`
# in that case, load the default values for behavior flags to avoid compilation errors
# this mimics not loading a project file, or not specifying flags in a project file
user_overrides = getattr(self.config, "flags", {})

self._behavior = Behavior(flags, user_overrides)

@property
def _behavior_flags(self) -> List[BehaviorFlag]:
Expand Down

0 comments on commit 105db3a

Please sign in to comment.