-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PsqlDosBackend
: Fix Node.store
excepting when inside a transaction (
#6125) Calling `Node.store` with the `PsqlDosBackend` would except whenever inside a transaction, for example, when iterating over a `QueryBuilder` result, which opens a transaction. The reason is that the node implementation of the `PsqlDosBackend`, the `SqlaNode.store` method calls `commit` on the session. This closes the current transaction, and so when it is then used again, for example in the next iteration of the builder results, an exception is raised by sqlalchemy complaining that the transaction was closed. The solution is that `SqlaNode.store` should only commit if it is not inside a nested transaction, otherwise it should simply flush the addition of the node to the session such that automatically generated primary keys are populated. A similar problem was addressed in the `add_nodes` and `remove_nodes` methods of the `SqlaGroup` class. These would also call `commit` at the end, regardless of whether they are called within an open transaction.
- Loading branch information
Showing
7 changed files
with
46 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters