function MergeTest::testMergeWithReservedWords
Same name in other branches
- 10 core/tests/Drupal/KernelTests/Core/Database/MergeTest.php \Drupal\KernelTests\Core\Database\MergeTest::testMergeWithReservedWords()
- 11.x core/tests/Drupal/KernelTests/Core/Database/MergeTest.php \Drupal\KernelTests\Core\Database\MergeTest::testMergeWithReservedWords()
Tests that we can merge-insert with reserved keywords.
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Database/ MergeTest.php, line 225
Class
- MergeTest
- Tests the MERGE query builder.
Namespace
Drupal\KernelTests\Core\DatabaseCode
public function testMergeWithReservedWords() {
$num_records_before = $this->connection
->query('SELECT COUNT(*) FROM {select}')
->fetchField();
$this->connection
->merge('select')
->key('id', 2)
->execute();
$num_records_after = $this->connection
->query('SELECT COUNT(*) FROM {select}')
->fetchField();
$this->assertEquals($num_records_before + 1, $num_records_after, 'Merge inserted properly.');
$person = $this->connection
->query('SELECT * FROM {select} WHERE [id] = :id', [
':id' => 2,
])
->fetch();
$this->assertEquals('', $person->update);
$this->assertEquals('2', $person->id);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.