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.
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
Changes to support bidirectional consent #5118
Changes to support bidirectional consent #5118
Changes from 8 commits
ca5f113
4715cbf
45ea791
c6817de
78b7da0
f93333a
9abb34f
e23a7cc
1e26d2a
f2312e9
fc76450
61f9df4
db52e9e
79fc16c
13ec623
3cf4ec6
622f8d8
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Can we add a test for this cascade functionality?
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.
Can we add a test for this cascade functionality, too?
Check warning on line 58 in src/fides/api/models/consent_automation.py
Codecov / codecov/patch
src/fides/api/models/consent_automation.py#L58
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.
can you explain how flush works? I haven't had to use this manually before
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.
flush()
lets you push changes to the database without committing the transaction. In this case, we just calleddb.add(item)
to add a newConsentableItem
to this current DB session, but if we want to get the ID for that new item, we can callflush()
and this would be executed in the current transactionSo it's enough for us to get an ID without us having to commit the current transaction. If any exceptions occur during later in the code (after
flush()
), we can still roll everything back as if nothing happened.Check warning on line 119 in src/fides/api/models/consent_automation.py
Codecov / codecov/patch
src/fides/api/models/consent_automation.py#L118-L119
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 is
remote_side
?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.
It's needed for self-referential relationships like what we're doing here with
ConsentableItem
. There's an in-depth explanation here but the way I was able to reason about it was that it's telling SQLAlchemy which side of the relationship is the "parent" or "one" side of a one-to-many relationship. As an example, oneConsentableItem
can have anid
of 1, but manyConsentableItems
can have theirparent_id
be 1, soid
would be the "remote_side".Check warning on line 25 in src/fides/api/schemas/consentable_item.py
Codecov / codecov/patch
src/fides/api/schemas/consentable_item.py#L25
Check warning on line 33 in src/fides/api/schemas/consentable_item.py
Codecov / codecov/patch
src/fides/api/schemas/consentable_item.py#L33