Hi Isomorphic,
I noticed a potential problem in BatchUploader with FK-lookup (importStrategy="display"). I'll describe it before creating a testcase, because it's not really a bug.
Imagine a numberish string like supplyItem.SKU. supplyItem still has itemID as sequence-PK.
The data looks like this:
Now I delete itemID=1
Now imagine I want to upload an item with SKU = "2" in the CSV, but it does not exist in the DB (because I deleted it). So the lookup for the SKU fails, and supplyItem_ID value is still 2 (=the value from the CSV).
Next, the DB-insert will be tried with supplyItem_ID=2, which does exist, so the insert will succeed, but the new row will link to a different item.
This problem can occur everywhere where the datatype of displayfield and datafield is the same or a cast succeeds.
Best regards
Blama
I noticed a potential problem in BatchUploader with FK-lookup (importStrategy="display"). I'll describe it before creating a testcase, because it's not really a bug.
Imagine a numberish string like supplyItem.SKU. supplyItem still has itemID as sequence-PK.
Code:
<field name="supplyItem_ID" importStrategy="display" uploadFieldName="SKU" displayField="SKU" foreignKey="supplyItem.itemID" required="true"> <title><fmt:message key="SKU" /></title> <validators> <validator type="hasRelatedRecord" /> </validators> </field>
The data looks like this:
Code:
itemID SKU 0 "1" 1 "2" 2 "3" ...
Now imagine I want to upload an item with SKU = "2" in the CSV, but it does not exist in the DB (because I deleted it). So the lookup for the SKU fails, and supplyItem_ID value is still 2 (=the value from the CSV).
Next, the DB-insert will be tried with supplyItem_ID=2, which does exist, so the insert will succeed, but the new row will link to a different item.
This problem can occur everywhere where the datatype of displayfield and datafield is the same or a cast succeeds.
Best regards
Blama
Comment