Fix parameter numbering with whereIn
This commit is contained in:
@@ -77,6 +77,7 @@ class Connection extends BaseConnection
|
||||
/** @inheritDoc */
|
||||
public function statement($query, $bindings = []): bool
|
||||
{
|
||||
$query = QueryGrammar::prepareParameters($query);
|
||||
return $this->run($query, $bindings, function ($query, $bindings) {
|
||||
return !$this->cluster->getActiveNode()->write($query, $bindings)->isError();
|
||||
});
|
||||
@@ -85,6 +86,7 @@ class Connection extends BaseConnection
|
||||
/** @inheritDoc */
|
||||
public function affectingStatement($query, $bindings = []): int
|
||||
{
|
||||
$query = QueryGrammar::prepareParameters($query);
|
||||
return (int)$this->statement($query, $bindings);
|
||||
}
|
||||
|
||||
|
||||
+1
-24
@@ -9,30 +9,7 @@ use Illuminate\Database\Query\Grammars\Grammar;
|
||||
|
||||
class QueryGrammar extends Grammar
|
||||
{
|
||||
const PARAMETER_SIGN = '#@?';
|
||||
|
||||
/** @inheritDoc */
|
||||
public function parameterize(array $values): string
|
||||
{
|
||||
$params = [];
|
||||
for ($i = 0; $i < count($values); $i++) {
|
||||
$params[] = ":$i";
|
||||
}
|
||||
|
||||
return implode(', ', $params);
|
||||
}
|
||||
|
||||
/** @inheritDoc */
|
||||
public function parameter($value)
|
||||
{
|
||||
return $this->isExpression($value) ? $this->getValue($value) : self::PARAMETER_SIGN;
|
||||
}
|
||||
|
||||
/** @inheritDoc */
|
||||
public function compileWheres(Builder $query)
|
||||
{
|
||||
return static::prepareParameters(parent::compileWheres($query));
|
||||
}
|
||||
const PARAMETER_SIGN = '?';
|
||||
|
||||
/**
|
||||
* Second part of trick to change signs "?" to ":0", ":1" and so on
|
||||
|
||||
@@ -23,7 +23,7 @@ class BindingsTest extends TestCase
|
||||
public function testBindingsByTableMethod()
|
||||
{
|
||||
$query = DB::table('examples')
|
||||
->where(function (Builder $q) {
|
||||
->where(function ($q) {
|
||||
$q->where('f_int', 1)
|
||||
->orWhere('f_int', 2)
|
||||
->orWhere('f_int', 3);
|
||||
|
||||
Reference in New Issue
Block a user