function MergeTest::testMergeWithoutInsertFieldsFallback
Tests that a merge without insert fields uses the generic emulation.
File
-
core/
modules/ pgsql/ tests/ src/ Kernel/ pgsql/ MergeTest.php, line 209
Class
- MergeTest
- Tests the native MERGE implementation of the PostgreSQL driver.
Namespace
Drupal\Tests\pgsql\Kernel\pgsqlCode
public function testMergeWithoutInsertFieldsFallback() : void {
$result = NULL;
$queries = $this->getLoggedQueries(function () use (&$result) {
$result = $this->connection
->merge('test_people')
->condition('job', 'Speaker')
->updateFields([
'age' => 31,
])
->execute();
});
// Without insert fields a WHEN NOT MATCHED THEN INSERT clause cannot be
// generated, so the generic emulation is used.
$this->assertSame(Merge::STATUS_UPDATE, $result);
foreach ($queries as $query) {
$this->assertStringNotContainsString('MERGE INTO', $query);
}
$age = $this->connection
->query('SELECT [age] FROM {test_people} WHERE [job] = :job', [
':job' => 'Speaker',
])
->fetchField();
$this->assertEquals(31, $age);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.