Skip to content

Commit

Permalink
datarow update for dupes fix!
Browse files Browse the repository at this point in the history
  • Loading branch information
JRSaunders committed Apr 15, 2021
1 parent f2b0866 commit 299e5f5
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/DB/Builder/QueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Illuminate\Pagination\Paginator;
use Illuminate\Support\Arr;
use Illuminate\Support\Collection;
use ShardMatrix\DB\DataRow;
use ShardMatrix\DB\Exception;
use ShardMatrix\DB\Interfaces\ResultsInterface;
use ShardMatrix\DB\Interfaces\ShardDataRowInterface;
Expand Down Expand Up @@ -191,7 +192,7 @@ public function toSqlHash(): string {
* @return Uuid|null
* @throws \ShardMatrix\Exception
*/
public function insert( array $values , ?Uuid $uuid = null): ?Uuid {
public function insert( array $values, ?Uuid $uuid = null ): ?Uuid {
$uuid = $uuid ?? Uuid::make( $this->getConnection()->getNode(), new Table( $this->from ) );
$values = array_merge( [ 'uuid' => $uuid->toString() ], $values );

Expand Down Expand Up @@ -225,12 +226,18 @@ public function insert( array $values , ?Uuid $uuid = null): ?Uuid {
*/
public function update( array $values ) {
if ( $this->uuid ) {

$rowData = (object) $values;
$rowData->uuid = $this->uuid->toString();
$dataRow = new DataRow( $rowData );

return $this->getShardDB()->uuidUpdate(
$this->uuid,
$this->grammar->compileUpdate( $this, $values ),
$this->cleanBindings(
$this->grammar->prepareBindingsForUpdate( $this->bindings, $values )
)
),
$dataRow
);
}

Expand Down

0 comments on commit 299e5f5

Please sign in to comment.