Conversation
…tors can validate the remapped value
experiment/src/org/labkey/experiment/api/property/LookupValidator.java
Outdated
Show resolved
Hide resolved
experiment/src/org/labkey/experiment/api/property/LookupValidator.java
Outdated
Show resolved
Hide resolved
…bstractAssayTsvDataHandler.checkData
| TableInfo lookupTable = remappableLookup.get(pd); | ||
| try | ||
| { | ||
| Object remapped = cache.remap(lookupTable, s, true); |
There was a problem hiding this comment.
If I have a item with label 4 (whose pk is 5), this will map input 4 to pk 4. It's probably not big deal, but it is inconsistent with how we resolve samples (ExperimentService.findExpMaterial).
|
@labkey-klum @labkey-jeckels would either of you like to also do a CR on this? |
I doubt (or hope not) that we would see a scenario in real life where the lookup resembles the PK but I think I agree with Xing's assessment that we should favor the primary key. |
| } | ||
| catch (ConversionException e) | ||
| { | ||
| errors.add(new PropertyValidationError(e.getMessage(), pd.getName())); |
There was a problem hiding this comment.
Will this exception always have a message, or should we fill in a generic one? (I see that this is moved code, but still could be relevant)
There was a problem hiding this comment.
This was existing code that I moved. However, I don't think the catch block is needed here. The remap code doesn't look to convert the value or throw the ConversionException. The error for a value that can't be mapped ends up in the code above this where remapped == null. So I believe we can remove this try/catch.
Adding @labkey-susanh in case she hasn't been following along. For TSV import, it seems more likely that the data provided would be the lookup value (a sample ID that happens to be a number, for example). However, I don't know the full details of the scenario that prompted this change. |
Yeah, in the absence of other information, I would tend toward resolving as a name first instead of as a PK first, especially since we know customers have number names. |
@labkey-susanh @labkey-jeckels @labkey-klum @XingY It looks like the code that is currently resolving the lookup value by pkColumn value and then titleColumn value is in SimpleTranslator.java |
Definitely agree it would be a separate PR If this PR didn't introduce a change in the ordering. I'm not sure we would reorder these statement for all (not something to be done on a whim) but might choose when or whether |
|
FYI, I am going to merge this change and then open a related issue with the details for the "resolve lookup value before PK" discussion. |
Rationale
Issue 53625: Assay result lookup field import fails when titleColumn value provided with "Ensure Value Exists in Lookup Target" checkbox enabled for lookup field
When an assay results domain has a look field with the "Ensure Value Exists in Lookup Target" enabled, we are currently throwing a
ConversionExceptionin the validator code because it is trying to validate if the provided value (which could be the key value for the lookup or the titleColumn value) is in the lookup table.This PR fixes that by catching the
ConversionExceptionin theLookupValidator.validate()method but also by making sure we first remap the provided value before checking the validators inAbstractAssayTsvDataHandler.checkData.Changes
Tasks 📍
If my lookup label is string type but the value is number like, for example "123", then import fails with "look: Value '123'was not present in lookup target 'lists.cRck" @cnathe