leomarquine / php-etl

Extract, Transform and Load data using PHP.
MIT License
178 stars 81 forks source link

Table.php needsUpdate() function is not returning the correct result if two fields have the same value #9

Closed lolaslade closed 6 years ago

lolaslade commented 6 years ago

In my example below the incoming data has an updated value for client_name which is the same as client_key. The old data in the table has a value for client_key but a NULL for client_name. This should trigger an update but it doesn't.

I suggest that the issue is in this line and the change is that we need to use array_diff_assoc instead of array_diff. https://github.com/leomarquine/php-etl/blob/4c3cbd2aed8fd170ee8cdf489335a66e26799d9d/src/Loaders/Table.php#L285

array(2) {
  ["client_key"]=>
  string(5) "Actual"
  ["client_name"]=>
  string(5) "Actual"
}
array(4) {
  ["id"]=>
  string(1) "1"
  ["client_key"]=>
  string(5) "Actual"
  ["client_name"]=>
  NULL
  ["client_access_key"]=>
  string(0) ""
}