-
Notifications
You must be signed in to change notification settings - Fork 4
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
MMO x DDL #186
Conversation
Package of operations that update 'visible columns' source definitions found in various annotations based on changes to named model elements.
Col, Key, FKey rename operations propogate name change to annotations.
@@ -1,15 +1,16 @@ | |||
|
|||
from __future__ import annotations | |||
|
|||
import base64 |
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.
Hmmm... this must be what pycharm meant by "optimizing" imports on commit. I'm gonna not do that in the future. If this is annoying I can revert this part but its just a reordering as far as I see.
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.
I think it's ok
Col, Key, FKey drop operations propagate name change to annotations.
Table drop operation propagates name removal to annotations.
Schema drop operation propagates name removal to annotations.
Drop table fix to clean up its implicitly dropped fkeys by pruning their names from all other table's annotations.
deriva/core/ermrest_model.py
Outdated
if update_mappings: | ||
for fkey in self.foreign_keys: | ||
mmo.prune(self.schema.model, [fkey.constraint_schema.name, fkey.constraint_name]) | ||
self.schema.apply() |
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.
Doesn't this have to be self.schema.model.apply? Changes could be global across any schema in the model, right?
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.
thanks. fixed
The absolute imports work better when invoking whole/sub trees of tests.
Fixing the apply() calls to always be rooted on the model not the current object's parent, since the annotation changes apply potentially throughout the entire catalog model.
Added a 'deferred' mode and made the 'update_mappings' parameter based on an enum representing the three modes. Refactored the pre/post cond logic in the test_mmo_drop unittests as it seemed over-engineered.
MMO primitives to find, prune, replace constraint names based on the schema name part only.
Support for updating mappings after a Table.alter(schema_name=...) change.
Fixed a bug in the bare constraint name case for schema name changes to be reflected in vizcol and vizfkey annotations.
On `schema.alter(schema_name=...)` all constraint names throughout supported annotation structures are updated.
nochange = NoChange() | ||
|
||
class UpdateMappings (str, Enum): | ||
"""Update Mappings flag enum""" | ||
no_update = '' | ||
deferred = 'deferred' | ||
immediate = 'immediate' | ||
|
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.
@karlcz think this is okay this way? or would it be better to have variable instances of the enum of say no_update = UpdateMappings.no_update
analogous to your nochange = NoChange()
instance?
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.
I think this is fine. You can use it as UpdateMappings.no_update
etc.
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.
However, I'm not sure I like the empty string... I think I'd also spell it out.
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.
Nevermind, I see you did it to make the "falsish" test easier to write below...
I think this is good to merge now. I didn't actually try to run the test suite though, as I'm not sure if/how it depends on the other open PR for mmo...? |
Cool. I have run the tests. It all succeeds.
|
Integration of MMO with DDL operations.