function SchemaTest::tryUnsignedInsert

Same name in other branches
  1. 8.9.x core/tests/Drupal/KernelTests/Core/Database/SchemaTest.php \Drupal\KernelTests\Core\Database\SchemaTest::tryUnsignedInsert()

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

Parameters

string $table_name: The table to insert.

string $column_name: The column to insert.

Return value

bool TRUE if the insert succeeded, FALSE otherwise.

1 call to SchemaTest::tryUnsignedInsert()
SchemaTest::testUnsignedColumns in core/tests/Drupal/KernelTests/Core/Database/SchemaTest.php
Tests creating unsigned columns and data integrity thereof.

File

core/tests/Drupal/KernelTests/Core/Database/SchemaTest.php, line 440

Class

SchemaTest
Tests table creation and modification via the schema API.

Namespace

Drupal\KernelTests\Core\Database

Code

public function tryUnsignedInsert($table_name, $column_name) {
    try {
        $this->connection
            ->insert($table_name)
            ->fields([
            $column_name => -1,
        ])
            ->execute();
        return TRUE;
    } catch (\Exception $e) {
        return FALSE;
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.