Skip to content

Update rollback syntax in Testing doc - #1723

Open
danielmbarlow wants to merge 2 commits into
neo4jrb:12from
danielmbarlow:patch-1
Open

Update rollback syntax in Testing doc#1723
danielmbarlow wants to merge 2 commits into
neo4jrb:12from
danielmbarlow:patch-1

Conversation

@danielmbarlow

@danielmbarlow danielmbarlow commented Sep 23, 2024

Copy link
Copy Markdown

When using the suggested code from the documentation:

# For the `neo4j` gem
config.around do |example|
  ActiveGraph::Base.transaction do |tx|
    example.run
    tx.failure
  end
end

We get this error:

NoMethodError:
       undefined method `failure' for an instance of Neo4j::Driver::Internal::InternalTransaction

The syntax is apparently now tx.rollback, however when the transaction has already been rolled back we get this error

     Neo4j::Driver::Exceptions::ClientException:
       Can't rollback, transaction has been rolled back

This pull request changes the documention to recommend:

  • Usage of the new syntax for rollback
  • A check to see if the transaction is open before rolling it back

@danielmbarlow
danielmbarlow changed the base branch from 11 to 12 December 22, 2025 16:38
@danielmbarlow

Copy link
Copy Markdown
Author

Let me know if there's anything you would like me to change in this little PR.

@klobuczek

Copy link
Copy Markdown
Member

Thanks @danielmbarlow. I just looked at your PR this week and was just surprised about the condition if tx.open?. Did you have to do it because of some error? In the context of activegraph the transaction should be always open if in scope.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants