Closed daissatou2 closed 2 years ago
@daissatou2 currently the mapping does not build unique_id
but just insert the rows from the state as is.
Can you add to the spec if:
@lakhassane it looks like this error is happening because there are two items in the message with the same species
. To mitigate this, can you please update the job to store the following in wildmeat_id
on tbl_wildmeat
:
foodItem['group_begin/group_food/species']
+ [the position of the item in the array]. This will make sure wildmeat_id
will always be unqiue.
We have already implemented something similar here: https://github.com/OpenFn/wcs-wildmeat/blob/master/jobs/2.d.Offtake.js#L80
@daissatou2 I added the position. Find run here: https://www.openfn.org/projects/wildmeat/runs/061adf9f-0f17-7122-a7d2-d18617b6b1f7
Describe the bug
Why are we trying to upsert the same tbl_wildmeat row two times? We should have a unique id for each row, but this error is telling us that we're updating the same row 2x.
To Reproduce
expression.js
Link to the job itself in Github: https://github.com/OpenFn/wcs-wildmeat/blob/master/jobs/2.b.consommationRurale.js
state.json
https://www.openfn.org/projects/wildmeat/messages/061a4b3f-0651-71c3-94d7-925c211c54b3
To test/resolve