-
Notifications
You must be signed in to change notification settings - Fork 127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Versioning issues on session.flush #79
Open
dtheodor
wants to merge
11
commits into
kvesteri:master
Choose a base branch
from
dtheodor:update_bug
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+359
−24
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
190a8d9
failing test
dtheodor 091d1b7
Fix erroneous set of Operation.UPDATE to newly created items
dtheodor a72ac1e
ignore pycharm files
dtheodor 82341e9
Tests for PK modifications within the same transaction
dtheodor 8227d02
Update internal dict keys when primary keys are modified mid-transaction
dtheodor e4c7bbe
Remove redundant function
dtheodor 6bca6e2
Don't save versions when an object is created and deleted in the same
dtheodor 73fe0db
Update the postgres UPDATE trigger
dtheodor 998c8bd
Update the postgres DELETE trigger
dtheodor 454f957
Document postgres INSERT trigger
dtheodor 95123e6
add comment in test
dtheodor File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,3 +34,6 @@ nosetests.xml | |
.mr.developer.cfg | ||
.project | ||
.pydevproject | ||
|
||
#Pycharm | ||
.idea |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is needed otherwise after deleting a version sql alchemy will by default set the transaction_id of the TransactionChange to NULL, which is never desired.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than this I think a better one would be:
This uses foreign keys for deletion, but at the same time marks the in memory objects as deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What was happening was that deleting an object of
ArticleVersion
was setting thetransaction_id
of theTransactionChanges
object to NULL, which was causing aAssertionError: Dependency rule tried to blank-out primary key column 'transaction_changes.transaction_id' on instance '<TransactionChanges at 0x7f7d17a544d0>'
error.Deleting a version object should never affect a
TransactionChanges
object imo (at least not through foreign key behavior). If for instance you have 2 newArticleVersion
s, deleting one of them should not affect the existing TransactionChanges that points to theArticleVersion
(Deleting both of them should, but that's a different story).With the above in mind, I don't think the
cascade='all, delete-orphan'
has a place here as it creates a wrong impression about what the motivation here is. Thepassive_deletes=True
does make sense. I set it topassive_deletes='all'
because according to documentation, if the changes object is in memory SQL Alchemy will still set the foreign key to NULL, which is not desired. This whole thing can also be avoided if we remove the.changes
attribute on the version class; it can still be accessed through the.transaction.changes
attribute chain.What does make sense is to use
cascade='all, delete-orphan'
on theTransaction->TransactionChanges
relation. When a whole transcation is deleted, the changes have to go away with it as well.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm thanks for pointing that out! I removed the generated changes attr from version classes.