sgn icon indicating copy to clipboard operation
sgn copied to clipboard

Phenotype Upload Fails with duplicate Stock names

Open dwaring87 opened this issue 2 years ago • 9 comments

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

dwaring87 avatar Jun 16 '22 12:06 dwaring87

Code should check and not allow duplicate names even between different type_ids.

lukasmueller avatar Jun 16 '22 15:06 lukasmueller

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

nmenda avatar Aug 03 '22 21:08 nmenda

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 avatar Sep 20 '22 19:09 lukasmueller

@lukasmueller I think I have a branch for this. Let me see if I can commit it

nmenda avatar Sep 21 '22 20:09 nmenda

Is that function also used by the list checking functions? They may need to be changed as well...

lukasmueller avatar Sep 22 '22 13:09 lukasmueller

@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

nmenda avatar Sep 22 '22 16:09 nmenda

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

nmenda avatar Sep 29 '22 15:09 nmenda

should we close this ticket?

lukasmueller avatar Oct 07 '22 14:10 lukasmueller

@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)

dwaring87 avatar Nov 17 '23 15:11 dwaring87