function SchemaTest::tryUnsignedInsert

Tries to insert a negative value into columns defined as unsigned.

Parameters

$table_name: The table to insert.

$column_name: The column to insert.

Return value

TRUE if the insert succeeded, FALSE otherwise.

1 call to SchemaTest::tryUnsignedInsert()
SchemaTest::testUnsignedColumns in drupal/core/modules/system/lib/Drupal/system/Tests/Database/SchemaTest.php
Tests creating unsigned columns and data integrity thereof.

File

drupal/core/modules/system/lib/Drupal/system/Tests/Database/SchemaTest.php, line 227
Contains Drupal\system\Tests\Database\SchemaTest.

Class

SchemaTest
Tests the Schema API.

Namespace

Drupal\system\Tests\Database

Code

function tryUnsignedInsert($table_name, $column_name) {
  try {
    db_insert($table_name)
      ->fields(array(
      $column_name => -1,
    ))
      ->execute();
    return TRUE;
  } catch (\Exception $e) {
    return FALSE;
  }
}