Framework: MS-SQL 2100 wherein parameters limit - Eagerloading

Created on 12 May 2014  路  6Comments  路  Source: laravel/framework

Since I am forced to use MSSQL at work I run into the 2100 mssql limit on parameters to the WHERE IN.

Eloquents eagerloading used this so on when pulling out bigger amount of data with eagerloading it fails.

Could we patch the "parameter builder in Laravel" to circumvent this if their is over 2100 parameteres in the where in on mssql?

Most helpful comment

All 6 comments

No plans to implement a fix for this right now.

Understandable. Can you maybe tell where I should look to patch this myself? Thx

I found its caused by PDO posible patch if someone need it on Builder.php

public function whereIn($column, $values, $boolean = 'and', $not = false)
{
    $type = $not ? 'NotIn' : 'In';

    // If the value of the where in clause is actually a Closure, we will assume that
    // the developer is using a full sub-select for this "in" statement, and will
    // execute those Closures, then we can re-construct the entire sub-selects.
    if ($values instanceof Closure)
    {
        return $this->whereInSub($column, $values, $boolean, $not);
    }

if(count($values)>800)
{
  return $this->whereRaw($column. ' IN ('.implode(',', $values).')');
}

    $this->wheres[] = compact('type', 'column', 'values', 'boolean');

    $this->addBinding($values, 'where');

    return $this;
}

if someone has another idea for this please :)

@eriksape You are potentially introducing an SQL injection possibility there. When only used with integer IDs it is fine (and it seems that is what you assumed as no quotes are being used) but it may be something to look out for.

is and old thread but thanks i going to check but now i don't use SQLServer, I use Maria now.

Was this page helpful?
0 / 5 - 0 ratings