Skip to content

Commit

Permalink
Fix bug in compileInsert with empty values with SQLite.
Browse files Browse the repository at this point in the history
  • Loading branch information
mathieutu committed Aug 4, 2017
1 parent 698a635 commit 9bbd4d3
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/Illuminate/Database/Query/Grammars/SQLiteGrammar.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@ public function compileInsert(Builder $query, array $values)
// grammar insert builder because no special syntax is needed for the single
// row inserts in SQLite. However, if there are multiples, we'll continue.
if (count($values) == 1) {
if (empty(reset($values))) {
return "insert into $table default values";
}

return parent::compileInsert($query, reset($values));
}

Expand All @@ -172,6 +176,19 @@ public function compileInsert(Builder $query, array $values)
return "insert into $table ($names) select ".implode(' union all select ', $columns);
}

/**
* Compile an insert and get ID statement into SQL.
*
* @param \Illuminate\Database\Query\Builder $query
* @param array $values
* @param string $sequence
* @return string
*/
public function compileInsertGetId(Builder $query, $values, $sequence)
{
return $this->compileInsert($query, $values);
}

/**
* Compile a truncate table statement into SQL.
*
Expand Down

0 comments on commit 9bbd4d3

Please sign in to comment.