-
-
Notifications
You must be signed in to change notification settings - Fork 136
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
make Category.slug unique #149
Conversation
0eeeeee
to
83aeee0
Compare
I fixed the tests and added one to ensure slug uniqueness. @epicserve Could you please review? |
Your PR looks good to me. I'm personally not excited about adding a breaking change though. This isn't a feature that I've seen requested by others and it's not one that I personally need since any time I need django-category functionality I use the abstract model 'categories.base.CategoryBase'. If I was voting I think I would vote on taking out |
Well, I think, that the current state might be also harmful. As a developer I would expect, that On the other hand, there is only broken migration, which can be easily fixed. And as I said, I can write data migration for that (maybe even with input needed to confirm the change). @epicserve If you can think of a use case, when the duplicated slugs are actually needed, I could also add some override variable (like |
83aeee0
to
6ac0c04
Compare
How would you write a data migration that would fix duplicates before applying the unique constraint? |
@epicserve I would prompt the user, and if he press 'y', I would select the duplicated categories and make sequence of them (if there is 3 times slug |
6ac0c04
to
0eeeeee
Compare
I don't think prompting the user would be good, because this wouldn't work for anyone that is using CI/CD. May it would be best to do a count by the slug field and then do as you suggest and incremental numbers for each duplicate. You would also want to let me people know in the README so that they're aware of what will happen. |
51b9b20
to
ec04851
Compare
a332b98
to
fa2a487
Compare
Hi @epicserve I have written the migration, it will add the sequence without prompting user. I created the migration tests. I had to fix #152 in order to make the |
4d54133
to
1604b00
Compare
0a35707
to
2dfab04
Compare
2dfab04
to
2a1fd77
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #149 +/- ##
==========================================
+ Coverage 65.78% 66.66% +0.88%
==========================================
Files 24 25 +1
Lines 1128 1143 +15
Branches 218 256 +38
==========================================
+ Hits 742 762 +20
+ Misses 292 290 -2
+ Partials 94 91 -3 ☔ View full report in Codecov by Sentry. |
I have rebased this on top of #167 |
3cf2340
to
d884af3
Compare
@coordt @epicserve I have updated this to the |
@PetrDlouhy, this looks pretty good to me at a quick glance. I would think this would need to be a 2.0 release since this is could potentially be a breaking change. Even though you're taking care of the duplicates with the data migration, I wonder if it could end up breaking someone's application if they are using a slug in some way that got changed from |
Is there more changes we want to make/merge before doing a 2.0 release? If so, I would recommend doing them all at once. |
@PetrDlouhy, I took a look at this, and I was going to make this commit to optimize the migration because the migration would be pretty slow on a large database. You would have to follow this guide to allow maintainers to contribute to your PR. The following is the patch for the commit I was going to make if you want to make that change. I think we would also want to update the docs explaining that this is a potential breaking change. I'm thinking this should be a 2.0 release.
|
98de0bb
to
e7da0a3
Compare
@epicserve Thank you for the patch, I applied it. I also added some note to CHANGELOG.md. Should there be any more info about this change? Thank you for the guide link, I didn't know about this. But I am not sure what else to set, because I already have that option enabled: |
Seems like |
@PetrDlouhy, your changes look good to me. Regarding allowing edits to PRs, I'm not sure what is happening. It could be that I'm no longer a maintainer of this project. @coordt, do you know? Regarding removing support for 2.1, that's fine with me. Especially since it's a new 2.0 version. According to the Django docs, only 3.2 and newer are supported by Django. I think it's good to match what Django supports. @coordt, do you have any thoughts on this and we can get this merged in and made into a release? |
@epicserve Can we get this merged? Is there any work left? |
@PetrDlouhy, probably. It would need to be a 2.0 release, I think. |
@epicserve Are there any plans for the 2.0 release? |
@PetrDlouhy I don't personally have plans. I think it would be great to get your contributions merged in, though. I'm unsure who is steering the ship anymore since Jazzband took over. @coordt, do you know? |
fc1cf1b
to
0e3ed41
Compare
I have at least rebased this and simplified the changelog. |
Since I have gained permissions to release new version and I have already released cleanup version 1.9.3, I also released this code as |
0e3ed41
to
539688e
Compare
This makes slug unique as mentioned in #116. I think it is very helpful in many usages of slug. This change could cause problems during migration, if the user have categories with duplicate slug.
I could make data migration which adds numbering to duplicate slugs, but I think it is better to let the the projects handle it by their own.