3093: prevent adding a duplicated repo name on reviewboard server
- Fixed
- Review Board
nan****@gmai***** (Google Code) (Is this you? Claim this profile.) | |
|
|
Jan. 18, 2014 |
What version are you running? 1.7.6 What's the URL of the page containing the problem? /admin/db/scmtools/repository/add What steps will reproduce the problem? 1. create a first repo with name "repository" (for example) 2. create a second one with same name "repository" could be reproduced using rest api too What is the expected output? prevent form being validated because a repository and notify submitter a repo with same name already exists What do you see instead? a 2nd repo with same name has been created, and review request on this repo will fail with error MultipleObjectsReturned: get() returned more than one Repository -- it returned 2! Lookup parameters were {} What operating system are you using? What browser? any In our case it happens often because we have already several repo defined (196) and people do not check everytime a repo name already exists on second page of repo list :-(
What database are you using? We have constraints in place to prevent duplicate names, but it does depend on the database to enforce it.
-
+ NeedInfo
our server is configured to use MySQL database. Ihave not checked yet if there is a uniq for repo name field
I've just checked, There is no unique=True for charfield name from repository class whereas there is one for tool.name https://github.com/reviewboard/reviewboard/blob/master/reviewboard/scmtools/models.py Will this kind of change (adding unique) be supported by a django-evolution script?
We do have a unique_together constraint with repository name and local site, but apparently those aren't enforced when one of the pair is null. I think we probably need to handle this in the admin form instead. See bug 3066 for a similar issue.
We use unique_together= in the Meta definition for the model. However, django-evolution does not appear to support this, so if your installation is from pre-1.6 days, that's probably it.
It seems that this problem wasn't really fixed as we can see it very often on 2.0.15 - see https://gist.githubusercontent.com/ssbarnea/53dba96497529e6b7d49/raw/f38c738768fd360104c5b175fa01b442a1c9cfc5/gistfile1.txt