Silent failure from Import Lookups by Alternate key

LabKey Support Forum (Inactive)
Silent failure from Import Lookups by Alternate key Will Holtz  2017-03-14 12:10
Status: Closed
 
1. Create list "Simple" and add field "Name"
2. Create list "WithFk" and add field "Lookup" that is a fk to list Simple
3. Go to list WithFk and click "Insert>Import Bulk Data"
4. In the Data text input box put:
Lookup
Foo
5. check "Import Lookups by Alternate Key"
6. Click "Submit"

I then get a dialog "Success, 1 row inserted" and the Lookup field of the new row is NULL. I expected this case to give me an error message and fail to insert the row. If I make Lookup a required field in WithFk, then the bulk insert does fail. However, my use case does not allow the field to be required.

Is this a bug or do my expectations not match the developers?

thanks,
-Will
 
 
kevink responded:  2017-03-14 13:34
The current behavior is to replace values that can't be mapped to the target lookup table will null if the column is not required. If you change the WithFk.Lookup column to be required, we will fail the import with an error message similar to:

Could not convert 'Foo' for field Lookup, should be of type Integer; Missing value for required property: Lookup

That said, it is a little confusing so I could imagine that we could change the requirements to be a little more strict instead of converting the value to null.
 
Will Holtz responded:  2017-03-14 13:46
Hi Kevin,

After I posted, I noticed that I should be able to change the WithFk list design such that the Lookup field has the Lookup Validator activated. Then the docs say, "An error will be displayed whenever you attempt to import a value that is not in the lookup's target table."

https://www.labkey.org/home/Documentation/wiki-page.view?name=lookupDefine#lookupvalidate

However, my above repo (plus turning on Lookup Validator), still inserts a row when the value cannot be mapped to the Simple list.

thanks for your help!

-Will