constraintExists example

$this->connection->expects($this->exactly(2))
      ->method('query')
      ->withConsecutive(
        [$this->anything()],
        ["SELECT 1 FROM pg_constraint WHERE conname = '$expected'"],
      )
      ->willReturnOnConsecutiveCalls(
        $statement,
        $this->createMock('\Drupal\Core\Database\StatementInterface'),
      );

    $schema->constraintExists($table_name$name);
  }

  /** * Data provider for ::testComputedConstraintName(). */
  public function providerComputedConstraintName() {
    return [
      ['user_field_data', 'pkey', 'user_field_data____pkey'],
      ['user_field_data', 'name__key', 'user_field_data__name__key'],
      ['user_field_data', 'a_very_very_very_very_super_long_field_name__key', 'drupal_WW_a8TlbZ3UQi20UTtRlJFaIeSa6FEtQS5h4NRA3UeU_key'],
    ];
  }
$this->connection->update($table)
        ->fields([$field => $spec['initial']])
        ->execute();
    }
    if ($fixnull) {
      $this->connection->query("ALTER TABLE {" . $table . "} ALTER $field SET NOT NULL");
    }
    if (isset($new_keys)) {
      // Make sure to drop the existing primary key before adding a new one.       // This is only needed when adding a field because this method, unlike       // changeField(), is supposed to handle primary keys automatically.       if (isset($new_keys['primary key']) && $this->constraintExists($table, 'pkey')) {
        $this->dropPrimaryKey($table);
      }
      $this->_createKeys($table$new_keys);
    }
    // Add column comment.     if (!empty($spec['description'])) {
      $this->connection->query('COMMENT ON COLUMN {' . $table . '}.' . $field . ' IS ' . $this->prepareComment($spec['description']));
    }
    $this->resetTableInformation($table);
  }

  
Home | Imprint | This part of the site doesn't use cookies.