{{ message }}
UniqueConstraint and Index withheld from table via attach_to_table flag, and appended to table via append_constraint#13399
Open
bekapono wants to merge 5 commits into
Open
Conversation
Contributor
Author
Member
This file contains hidden or 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
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.

Description
attach_to_table has been included for UniqueConstraint and Index to allow users to choose whether to include or withhold them from the Table (Table.constraints for UniqueConstraint, Table.indexes for Index). attach_to_table defaults to True for both UniqueConstraint and Index. So if set to True or not included UniqueConstraint / Index will be added to the Table.
For UniqueConstraint, setting attach_to_table to False prevents
parent.constraints.add(self)from executing inColumn._set_parent(). attach_to_table is checked viagetattrFor Index, setting attach_to_table to False prevents
table.indexes.add(self)from executing inIndex._set_parent()force_attach has been included in
Table.append_constraints(), and carried via**kw, to allow users to override attach_to_table. For situations where UniqueConstraint or Index was defined before the Table creation and attach_to_table is set to False, users can use that same UniqueConstraint or Index to append to table at a later time. For exampleunique_constraint = UniqueConstraint("x", attach_to_table=False)orindex = Index("x", attach_to_table=False), then Table is defined, thenTable.append_constraint(unique_constraint)orTable.append_constraint(index).For UniqueConstraint, regardless of attach_to_table, using
Table.append_constraint(constriant)allows for execution ofparent.constraints.add(self)inColumn._set_parent().For Index, regardless of attach_to_table, using
Table.append_constraint(index)allows for execution oftable.indexes.add(self)inIndex._set_parent().Fixes: #13048
Checklist
This pull request is:
must include a complete example of the issue. one line code fixes without an
issue and demonstration will not be accepted.
Fixes: #<issue number>in the commit messageinclude a complete example of how the feature would look.
Fixes: #<issue number>in the commit messageHave a nice day!