Skip to content

Commit d0db954

Browse files
committed
Base class get_context returns an empty dict
1 parent 7661e28 commit d0db954

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

backend/infrahub/database/__init__.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,12 @@ def is_transaction(self) -> bool:
183183
return False
184184

185185
def get_context(self) -> dict[str, Any]:
186-
return {
187-
"queries_names_to_config": self.queries_names_to_config,
188-
}
186+
"""
187+
This method is meant to be overridden by subclasses in order to fill in subclass attributes
188+
to methods returning a copy of this object using self.__class__ constructor.
189+
"""
190+
191+
return {}
189192

190193
def add_schema(self, schema: SchemaBranch, name: Optional[str] = None) -> None:
191194
self._schemas[name or schema.name] = schema
@@ -205,6 +208,7 @@ def start_session(self, read_only: bool = False, schemas: Optional[list[SchemaBr
205208
db_manager=self.manager,
206209
driver=self._driver,
207210
session_mode=session_mode,
211+
queries_names_to_config=self.queries_names_to_config,
208212
**context,
209213
)
210214

@@ -219,6 +223,7 @@ def start_transaction(self, schemas: Optional[list[SchemaBranch]] = None) -> Inf
219223
driver=self._driver,
220224
session=self._session,
221225
session_mode=self._session_mode,
226+
queries_names_to_config=self.queries_names_to_config,
222227
**context,
223228
)
224229

backend/tests/helpers/query_benchmark/db_query_profiler.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ class InfrahubDatabaseProfiler(InfrahubDatabase):
171171
def __init__(self, query_analyzer: QueryAnalyzer, **kwargs: Any) -> None:
172172
super().__init__(**kwargs)
173173
self.query_analyzer = query_analyzer
174+
# Note that any attribute added here should be added to get_context method.
174175

175176
def get_context(self) -> dict[str, Any]:
176177
ctx = super().get_context()

0 commit comments

Comments
 (0)