-
Notifications
You must be signed in to change notification settings - Fork 90
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
Add support for composite unique constraint in auto migration #984
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## master #984 +/- ##
==========================================
- Coverage 92.78% 89.72% -3.07%
==========================================
Files 108 109 +1
Lines 8182 8399 +217
==========================================
- Hits 7592 7536 -56
- Misses 590 863 +273 ☔ View full report in Codecov by Sentry. |
@dantownsend I hope it's not a problem, but I have approved and run the workflow for this PR. I have already tried these changes in the @atkei local branch and in my case everything works great as I wrote in this comment. Can you try and review this PR. Thanks. |
@sinisaos @dantownsend - could you make a hint - when it would be merged? Would it mean new version/release? |
@AlexanderMakarov I'll try my best to review it properly this week. |
Currenty looking for this funtionality - would appreciate it someone on the team would be able to review! |
@sinisaos @dantownsend - do you have some plans to deliver this functionality soon? Thank you in advance. |
@AlexanderMakarov Sorry, but you have to wait for @dantownsend response. |
Yes, it's definitely high on my radar. I need to try and get some improvements done to Piccolo Admin, but this is high on my list. Thanks for the patience. |
@dantownsend Is this released? |
@dantownsend is there any workaround to acheive this? |
@devsarvesh92 For now, the workaround is to use raw sql (in migrations or script) to add a composite unique constraint, as described here. |
@dantownsend Any advances on this getting merged & released? |
Hi, great to see this coming! For sure support for composite unique indexes/constraints is a real use case! I just wanted to introduce here a related question that is… why not make this to also support non-unique composite indexes? After all, the uniqueness is “only” an attribute of the index, isn’t it? For sure, if in the future support for composite PKs/FKs is added, then the composite UK will need to be considered again (because FKs should be able to point to UKs too. But right now (after having read various issues here), that seems to be not trivial to happen. So, back to the question, why not get the opportunity of this PR to, also, support non unique indexes? Ciao :) Disclaimer: I’m completely new to Piccolo, so maybe what I’m asking doesn’t make much sense or already can be done (apart from doing it in manual migrations), but from the research that I’m doing over various Python ORM libraries, where Piccolo is one of the “finalists”, this is pretty much, the only feature that I’m missing right now, so just sharing. |
when will it be merged? |
Same here, this is the only feature I'm missing with Piccolo, so adding a friendly bump. Really enjoying this ORM so far thanks. One question: would it be possible to reflect on the unique constraints of a model at runtime? That would be very useful, to generically handle e.g. conflicts during inserts. |
@pavdwest If anyone wants to use unofficial support (until is officially supported in Piccolo) for this PR, I've made a branch in my fork that combines this PR with the pip install https://github.com/sinisaos/piccolo/archive/dev.zip As far as I was able to try everything works fine. Hope this helps until everything is officially supported in Piccolo. |
Thank you very much @sinisaos, I've had a quick test of this branch::
Great stuff! |
@pavdwest Thank you, I'm glad you find that branch useful until all that will be officially supported.
Yes, you are right, but I don't know how to solve that because of the limited support for |
Related to #172, #175 and based on #957.
Add
UniqueConstraint
to support composite unique constraint in auto migration.Some work remains such as adding doc and testing, but I would like to have feedback on my proposal first.