-
Notifications
You must be signed in to change notification settings - Fork 6
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
Introduce optimization item delete()
#163
Open
glatterf42
wants to merge
9
commits into
fix/column-names-property-type
Choose a base branch
from
enh/introduce-optimization-item-delete
base: fix/column-names-property-type
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.
Open
Introduce optimization item delete()
#163
glatterf42
wants to merge
9
commits into
fix/column-names-property-type
from
enh/introduce-optimization-item-delete
Conversation
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
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## fix/column-names-property-type #163 +/- ##
================================================================
+ Coverage 88.5% 88.6% +0.1%
================================================================
Files 223 223
Lines 8117 8192 +75
================================================================
+ Hits 7189 7264 +75
Misses 928 928
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
One more piece we need to complete functionality also offered by ixmp: this PR adds
delete()
functions for all optimization items as a whole.I tried to achieve this using sqlalchemy's cascades, which are recommended as the higher-performing option in their docs (compared to loading all elements from collections before
delete()
ing them piecewise).Note
While the docs say this requires special setup for SQLite, we already have this exact setup, so can employ this immediately.
With the current setup,
IndexSet
s cannot be deleted if they are used by some other object. IIRC, this is a requirement that @danielhuppmann mentioned at some point, which we seem to get almost for free due to our setup: theIndexSet.id
columns in the e.g.TableIndexSetAssociation
cannot beNULL
; thus, when one tries to delete anIndexSet
while it is linked to aTable
(i.e. recorded inTableIndexSetAssociation
), anIntegrityError/DeletionPrevented
will be raised.All other optimization items should also theoretically be able to raise
DeletionPrevented
, but in practice, no other item relies on theirid
s not beingNULL
somewhere, so I'm not sure how else to check this. This is the only kind ofTODO
mark appearing inline.However, I'm also not sure we need to check this as the same kind of behavior is checked by the
IndexSet
tests or may not be relevant for the other objects.TODO