You are here

public function SelectQueryTest::testParameterLimit in Drupal driver for SQL Server and SQL Azure 8

Test the 2100 parameter limit per query.

File

src/Tests/SelectQueryTest.php, line 109
Definition of Drupal\sqlsrv\Tests\SelectQueryTest.

Class

SelectQueryTest
General tests for SQL Server database driver.

Namespace

Drupal\sqlsrv\Tests

Code

public function testParameterLimit() {
  $values = array();
  for ($x = 0; $x < 2200; $x++) {
    $values[] = uniqid($x, TRUE);
  }
  $query = db_select('test_task', 't');
  $query
    ->addExpression('COUNT(task)', 'num');
  $query
    ->where('t.task IN (:data)', array(
    ':data' => $values,
  ));
  $result = NULL;

  // If > 2100 we can get SQL Exception! The driver must handle that.
  try {
    $result = $query
      ->execute()
      ->fetchField();
  } catch (\Exception $err) {
  }
  $this
    ->assertEqual($result, 0, 'Returned the correct number of total rows.');
}