Skip to content
Permalink
Browse files

formatting

  • Loading branch information...
taylorotwell committed Aug 19, 2019
1 parent ca15be4 commit 46d7e96ab3ab59339ef0ea8802963b2db84f9ab3
@@ -2648,7 +2648,7 @@ public function insert(array $values)
}
/**
* Insert ignore a new record into the database.
* Insert a new record into the database while ignoring errors.
*
* @param array $values
* @return int
@@ -881,7 +881,7 @@ public function compileInsert(Builder $query, array $values)
*/
public function compileInsertOrIgnore(Builder $query, array $values)
{
throw new RuntimeException('This database engine does not support insert or ignore.');
throw new RuntimeException('This database engine does not support inserting while ignoring errors.');
}
/**
@@ -2,6 +2,7 @@
namespace Illuminate\Database\Query\Grammars;
use Illuminate\Support\Str;
use Illuminate\Database\Query\Builder;
use Illuminate\Database\Query\JsonExpression;
@@ -63,7 +64,7 @@ public function compileSelect(Builder $query)
*/
public function compileInsertOrIgnore(Builder $query, array $values)
{
return substr_replace($this->compileInsert($query, $values), ' ignore', 6, 0);
return Str::replaceFirst('insert', 'insert ignore', $this->compileInsert($query, $values));
}
/**
@@ -217,11 +217,7 @@ public function compileInsertOrIgnore(Builder $query, array $values)
*/
public function compileInsertGetId(Builder $query, $values, $sequence)
{
if (is_null($sequence)) {
$sequence = 'id';
}
return $this->compileInsert($query, $values).' returning '.$this->wrap($sequence);
return $this->compileInsert($query, $values).' returning '.$this->wrap($sequence ?: 'id');
}
/**
@@ -187,7 +187,7 @@ public function compileInsert(Builder $query, array $values)
*/
public function compileInsertOrIgnore(Builder $query, array $values)
{
return substr_replace($this->compileInsert($query, $values), ' or ignore', 6, 0);
return Str::replaceFirst('insert', 'insert or ignore', $this->compileInsert($query, $values));
}
/**
@@ -1870,7 +1870,7 @@ function (Builder $query) {
public function testInsertOrIgnoreMethod()
{
$this->expectException(RuntimeException::class);
$this->expectExceptionMessage('This database engine does not support insert or ignore.');
$this->expectExceptionMessage('does not support');
$builder = $this->getBuilder();
$builder->from('users')->insertOrIgnore(['email' => 'foo']);
}
@@ -1902,7 +1902,7 @@ public function testSQLiteInsertOrIgnoreMethod()
public function testSqlServerInsertOrIgnoreMethod()
{
$this->expectException(RuntimeException::class);
$this->expectExceptionMessage('This database engine does not support insert or ignore.');
$this->expectExceptionMessage('does not support');
$builder = $this->getSqlServerBuilder();
$builder->from('users')->insertOrIgnore(['email' => 'foo']);
}

0 comments on commit 46d7e96

Please sign in to comment.
You can’t perform that action at this time.