sgn
sgn copied to clipboard
Phenotype Upload Fails with duplicate Stock names
Expected Behavior
We have a breeder who was able to upload a set of Seedlots and then create a Trial where the Plots in the Trial had the same set of names as the Seedlots. So afterwards there as a Seedlot named "SI_Urb_22-1" and a Plot named "SI_Urb_22-1".
Then, she went to upload the phenotype observations for the trial, where the observationunit_name
was set to the Plot name and the upload silently fails because the upload doesn't know which Stock to assign the values to.
The stock table has a constraint for unique organism/uniquename/type combination, so having the same name for different stock types is allowed at the database level. Should the stock names be unique across all stock types?
The phenotype upload seems to lookup the stock entry just by name. Should it filter the stocks by type (plot, subplot, plant, etc) so that way the Seedlot entry does not conflict with the Plot entry?
For Bugs:
Environment
Steps to Reproduce
Code should check and not allow duplicate names even between different type_ids.
If we want to globally use only unique stock names then the stock object 'exists_in_database' function needs to be changed to lookup without type_id and organism_id
https://github.com/solgenomics/sgn/blob/master/lib/CXGN/Stock.pm#L687
Hi Naama, I think that's the right thing to do... Would you like to implement this fix or should I go ahead and do it?
@lukasmueller I think I have a branch for this. Let me see if I can commit it
Is that function also used by the list checking functions? They may need to be changed as well...
@lukasmueller need to check everything that uses StockLookup https://github.com/solgenomics/sgn/blob/master/lib/CXGN/Stock/StockLookup.pm#L53https://github.com/solgenomics/sgn/blob/master/lib/CXGN/Stock/StockLookup.pm#L53
https://github.com/solgenomics/sgn/tree/topic/unique_seedlot_names
Need to check other stock objects and make sure the uniqueness checks are not using type_id and/or organism_id
should we close this ticket?
@lukasmueller @nmenda This is still a problem. It is still possible to upload a file of seedlots using plot names, which causes a lot of problems later on (when uploading trait observations with those plot names)