You are here

function DatabaseReservedKeywordTestCase::testMergeReservedWordTable in Drupal 7

File

modules/simpletest/tests/database_test.test, line 4381

Class

DatabaseReservedKeywordTestCase
Test reserved keyword handling (introduced for MySQL 8+)

Code

function testMergeReservedWordTable() {
  $key = db_query('SELECT id FROM {virtual} LIMIT 1')
    ->fetchField();
  $num_records_before = db_query('SELECT COUNT(*) FROM {virtual}')
    ->fetchField();
  db_merge('virtual')
    ->key(array(
    'id' => $key,
  ))
    ->fields(array(
    'function' => 'Merged function',
  ))
    ->execute();
  $num_records_after = db_query('SELECT COUNT(*) FROM {virtual}')
    ->fetchField();
  $this
    ->assertIdentical($num_records_before, $num_records_after, 'Successful merge query on a table with a name and column which are reserved words.');
}