Skip to content

Commit

Permalink
Merge pull request #571 from opencybersecurityalliance/k2-kestrel-too…
Browse files Browse the repository at this point in the history
…l-suffix-fix

fix phantom read bug in sqlalchemcy interface
  • Loading branch information
subbyte authored Jul 30, 2024
2 parents 7f3dded + 4596cd6 commit 212949d
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,15 @@ def evaluate_graph(
if not instructions_to_evaluate:
instructions_to_evaluate = graph.get_sink_nodes()
for instruction in instructions_to_evaluate:
# connection is renewed for each instruction to evaluate
conn = self.engines[graph.store].connect()
# we also need a clean copy of the graph for reference resolution
# otherwise, we will refer to the subquery in previous for iteration
# which will give empty results
_graph = graph.deepcopy()

translator = self._evaluate_instruction_in_graph(
conn, graph, cache, instruction
conn, _graph, cache, instruction
)
# TODO: may catch error in case evaluation starts from incomplete SQL
sql = translator.result()
Expand Down Expand Up @@ -120,7 +125,7 @@ def evaluate_graph(
trunk = (
instruction.predecessor
if hasattr(instruction, "predecessor")
else graph.get_trunk_n_branches(instruction)[0]
else _graph.get_trunk_n_branches(instruction)[0]
)
if isinstance(trunk, Information):
df = variable_attributes_to_dataframe(df)
Expand Down

0 comments on commit 212949d

Please sign in to comment.