Skip to content

Commit

Permalink
Optimize builder insert (#33)
Browse files Browse the repository at this point in the history
* remove array_flatten from builder insert, added skip sort flag in builder insert
* fix style
  • Loading branch information
evsign authored Oct 12, 2020
1 parent 3aa5dda commit 9a5f101
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/Integrations/Laravel/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,13 @@ public function insertFile(array $columns, $file, string $format = Format::CSV):
* Performs insert query.
*
* @param array $values
* @param bool $skipSort
*
* @throws \Tinderbox\ClickhouseBuilder\Exceptions\GrammarException
*
* @return bool
*/
public function insert(array $values)
public function insert(array $values, bool $skipSort = false)
{
if (empty($values)) {
return false;
Expand All @@ -162,17 +163,14 @@ public function insert(array $values)
* in the same order for the record. We need to make sure this is the case
* so there are not any errors or problems when inserting these records.
*/
else {
elseif (!$skipSort) {
foreach ($values as $key => $value) {
ksort($value);
$values[$key] = $value;
}
}

return $this->connection->insert(
$this->grammar->compileInsert($this, $values),
array_flatten($values)
);
return $this->connection->insert($this->grammar->compileInsert($this, $values));
}

/**
Expand Down

0 comments on commit 9a5f101

Please sign in to comment.