Skip to content
Discussion options

You must be logged in to vote

Yes—this is supported in Piccolo 1.36.0. The PR you found was merged, and the 1.36.0 release includes composite unique constraints, with a foreign-key example.

Add this to your existing Table class after the two column declarations:

from piccolo.constraints import Unique

# Inside your existing Table class, after stone and price_list:
unique_stone_price_per_list = Unique([stone, price_list])

That enforces uniqueness of the pair, so either individual foreign key may still appear in other pairs. The final API is Unique, rather than the intermediate UniqueConstraint / add_unique_constraint syntax discussed in the PR.

For a new table, create_table() creates it. For an existing table, changing…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by d3r1n
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants