-
-
Notifications
You must be signed in to change notification settings - Fork 616
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
✨ Allow setting unique
in Field()
for a column
#83
✨ Allow setting unique
in Field()
for a column
#83
Conversation
I think that a column is not the right place for a unique constraint. And there can be more than one unique constraints for a table. The natural representation for a unique constraint is a list of columns. And a unique constraint should have a name. |
I think a column can perfectly be the right place for a unique constraint, if the unicity constraint is on one column only. The possibility to create constraints on multiple columns should of course exist as well, but adding a nameless unique constraint to a single column is a pretty common use case. And it seems people from postgresql agree : https://www.postgresql.org/docs/current/ddl-constraints.html#DDL-CONSTRAINTS-UNIQUE-CONSTRAINTS. |
Hi @christophelec! I would also set |
dd9dc12
to
4a29185
Compare
Any updates? |
4a29185
to
66156d4
Compare
Waiting the merge. |
66156d4
to
2b39e32
Compare
unique
in Field()
for a column
Awesome! Thanks for writing thorough tests @raphaelgibson! 🚀 🙇 🍰 This will be available in SQLModel |
📝 Docs preview for commit c2c6670 at: https://630aacc9a5277f58b9062b3e--sqlmodel.netlify.app |
Codecov Report
@@ Coverage Diff @@
## main #83 +/- ##
==========================================
+ Coverage 97.70% 97.72% +0.02%
==========================================
Files 185 186 +1
Lines 6133 6203 +70
==========================================
+ Hits 5992 6062 +70
Misses 141 141
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
Add unique constraint param to Field function to create unique columns.
I have added tests for these modifications.