-
Notifications
You must be signed in to change notification settings - Fork 91
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
Composite constraints #1146
Draft
dantownsend
wants to merge
31
commits into
master
Choose a base branch
from
composite-constraints
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.
Draft
Composite constraints #1146
Changes from 15 commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
ca4c4a2
Add support for composite unique constraint
atkei 07f8b94
Fix code format
atkei e4a5209
Add tests
atkei dc539bf
Merge branch 'master' into composite-unique-constraint-2
atkei 012c608
Add comments
atkei c7ce718
Merge branch 'master' into composite-constraints
dantownsend fb02cd5
`add_constraints` method
dantownsend 074e273
change module name from `contraint` to `constraints`
dantownsend a953b99
refactor -> `add_unique_constraint`
dantownsend f62205f
update docs
dantownsend 4e1b8e5
add check constraints
dantownsend e92aca2
make sure `CheckConstraint` works in migrations
dantownsend 3f5d6ea
fix typo in check condition ddl statement
dantownsend acd341d
remove unused import
dantownsend 5e7e201
improve docstring
dantownsend fae32e4
refactor to use `constraints` list on `Table`
dantownsend f369b81
update the docs
dantownsend 0c6d0cf
improve logic for getting `Table.constraints`
dantownsend 400046f
try lambda
dantownsend 7bc9a2e
strings
dantownsend 388e89f
Revert "strings"
dantownsend 83dad23
added `querystring_for_constraint`
dantownsend dc56104
stop using `constraints` list
dantownsend b3039d5
update `_table_str`
dantownsend 0963b58
update tests
dantownsend cc107b9
update tests
dantownsend 423c40c
fix linter errors
dantownsend 7995249
update docstrings
dantownsend 1b9e178
Update constraints.rst
dantownsend b712fb1
add docs for using constraints with mixins
dantownsend f49edf0
make sure dates can be used in check constraints
dantownsend 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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
=========== | ||
Constraints | ||
=========== | ||
|
||
Unique constraints | ||
================== | ||
|
||
Single column | ||
------------- | ||
|
||
Unique constraints can be added to a single column using the ``unique=True`` | ||
argument of ``Column``: | ||
|
||
.. code-block:: python | ||
|
||
class Band(Table): | ||
name = Varchar(unique=True) | ||
|
||
Multi-column | ||
------------ | ||
|
||
Use the ``add_unique_constraint`` method to add a multi-column constraint to a | ||
``Table``: | ||
|
||
.. currentmodule:: piccolo.table | ||
|
||
.. automethod:: Table.add_unique_constraint | ||
|
||
------------------------------------------------------------------------------- | ||
|
||
Check constraints | ||
================= | ||
|
||
.. automethod:: Table.add_check_constraint | ||
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.
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.
@dantownsend For now, constraints are droped by simply deleting (or commenting out) the constraints from the table definition. I'm fine with that, but it should be indicated in the docs so the user knows how to use that. Another option is to create a
drop_unique_constraint
classmethod that will drop the constraints. As you wish, both options suit me.