Skip to content

Commit

Permalink
Backport fix from UXDM v2.7.1
Browse files Browse the repository at this point in the history
  • Loading branch information
DivineOmega committed Apr 23, 2019
1 parent 62e620d commit 9c92ffc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 6 additions & 2 deletions src/Objects/Destinations/EloquentDestination.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,15 @@ private function updateDataRow(DataRow $dataRow)
{
$keyDataItems = $dataRow->getKeyDataItems();

$this->model->where(function ($query) use ($keyDataItems) {
$records = $this->model->where(function ($query) use ($keyDataItems) {
foreach ($keyDataItems as $keyDataItem) {
$query->where($keyDataItem->fieldName, $keyDataItem->value);
}
})->update($this->getAssocArrayFromDataRow($dataRow));
})->get();

foreach($records as $record) {
$record->update($this->getAssocArrayFromDataRow($dataRow));
}
}

public function putDataRows(array $dataRows): void
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/EloquentDestinationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ private function getDestination()
$stmt = $this->pdo->prepare($sql);
$stmt->execute();

$sql = 'CREATE TABLE IF NOT EXISTS users (name TEXT, value INTEGER)';
$sql = 'CREATE TABLE IF NOT EXISTS users (id integer primary key autoincrement, name TEXT, value INTEGER)';
$stmt = $this->pdo->prepare($sql);
$stmt->execute();

Expand Down Expand Up @@ -60,7 +60,7 @@ private function alterDataRows(array $dataRows)

private function getActualArray()
{
$sql = 'SELECT * FROM users';
$sql = 'SELECT name, value FROM users';
$stmt = $this->pdo->prepare($sql);
$stmt->execute();

Expand Down

0 comments on commit 9c92ffc

Please sign in to comment.