function MergeTest::testMergeSqlString
Tests the SQL string of a native merge query.
File
-
core/
modules/ pgsql/ tests/ src/ Kernel/ pgsql/ MergeTest.php, line 42
Class
- MergeTest
- Tests the native MERGE implementation of the PostgreSQL driver.
Namespace
Drupal\Tests\pgsql\Kernel\pgsqlCode
public function testMergeSqlString() : void {
$sql = (string) $this->connection
->merge('test_people')
->key('job', 'Speaker')
->fields([
'age' => 31,
'name' => 'Tiffany',
])
->useDefaults([
'job',
])
->expression('age', '[age] + :age', [
':age' => 4,
]);
$this->assertStringContainsString('MERGE INTO {test_people} USING (SELECT 1) AS drupal_merge_source ON', $sql);
$this->assertStringContainsString('WHEN MATCHED THEN UPDATE SET', $sql);
$this->assertStringContainsString('WHEN NOT MATCHED THEN INSERT', $sql);
$this->assertStringContainsString('DEFAULT', $sql);
$this->assertStringContainsString('RETURNING merge_action()', $sql);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.