piccolo icon indicating copy to clipboard operation
piccolo copied to clipboard

Are there constraints

Open BezBartek opened this issue 2 years ago • 3 comments

Hello, can we define constraints over the table? Similar to Django, I am requesting for:

Check constraints Unique constraints

Thank you!

BezBartek avatar Mar 06 '23 15:03 BezBartek

Unique constraints are possible:

class MyTable(Table):
    name = Varchar(unique=True)

We don't currently have unique together constraints, but it's often requested, so I'll add it soon. Likewise with check constraints.

dantownsend avatar Mar 06 '23 15:03 dantownsend

You can add them directly to your database using SQL, and it should be OK.

dantownsend avatar Mar 06 '23 15:03 dantownsend

@dantownsend Ye, thank you, I did that In the case of Unique constraints, I mean a lack of ability to set a conditional unique constraint, like: Unique application and status when status is pending. I used to write a lot of constraints like that, they are really helpful to prevent any corrupted data in huge complicated systems

BezBartek avatar Mar 06 '23 22:03 BezBartek