public function SelectQueryTest::testDuplicatePlaceholders in Drupal driver for SQL Server and SQL Azure 8
Although per official documentation you cannot send duplicate placeholders in same query, this works in mySQL and is present in some queries, even in core, wich have not gotten enough attention.
File
- src/
Tests/ SelectQueryTest.php, line 135 - Definition of Drupal\sqlsrv\Tests\SelectQueryTest.
Class
- SelectQueryTest
- General tests for SQL Server database driver.
Namespace
Drupal\sqlsrv\TestsCode
public function testDuplicatePlaceholders() {
$query = db_select('test_task', 't');
$query
->addExpression('COUNT(task)', 'num');
$query
->where('t.task IN (:data0, :data0)', array(
':data0' => 'sleep',
));
$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, 2, 'Returned the correct number of total rows.');
}