Skip to content

Commit

Permalink
Force statement execution before execution error check
Browse files Browse the repository at this point in the history
It's necessary to call a method on the result within the try block. Any method will do; has_next() is one of the cheapest ones to call.

Resolves #28.
  • Loading branch information
johannessen committed Dec 11, 2024
1 parent e7ca25a commit 985656d
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/REST/Neo4p/Agent/Neo4j/Driver.pm
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ sub run_in_session {
$params = {} unless defined $params;
try {
$self->{_last_result} = $self->session->run($qry, $params);
$self->{_last_result}->has_next; # Make sure the query has executed and any errors have been thrown
} catch {
$self->{_last_errors} = $_;
};
Expand All @@ -243,6 +244,7 @@ sub run_in_transaction {
$params = {} unless defined $params;
try {
$self->{_last_result} = $tx->run($qry, $params);
$self->{_last_result}->has_next; # Make sure the query has executed and any errors have been thrown
} catch {
$self->{_last_errors} = $_;
};
Expand Down

0 comments on commit 985656d

Please sign in to comment.