<?php

declare(strict_types=1);

namespace PpPhp\Core\Database\Dialect;

/**
 * CockroachDB adapter.
 *
 * CockroachDB speaks the PostgreSQL wire protocol and is consumed through the
 * same PDO_PGSQL driver, so it inherits the entire PostgreSQL dialect — schema
 * qualification, `GENERATED BY DEFAULT AS IDENTITY` auto keys (supported since
 * CockroachDB v22.1), JSONB, information_schema / pg_catalog introspection and
 * transactional DDL all carry over unchanged. This subclass exists so the
 * engine is a first-class, correctly-labelled choice in the designer with its
 * own default port (26257), rather than masquerading as plain Postgres.
 *
 * The two behaviours to keep an eye on against a live cluster (both inherited
 * from PostgreSqlDialect, neither exercised by table CREATE):
 *   • `ALTER COLUMN … TYPE … USING` in updateTable — CockroachDB supports most
 *     type changes but a few require a session setting; a create-then-recreate
 *     is the safe fallback if a specific change is rejected.
 *   • dropDatabase connects to the `postgres` maintenance database, which
 *     CockroachDB provides by default.
 */
final class CockroachDbDialect extends PostgreSqlDialect
{
    public function id(): string { return 'cockroachdb'; }

    public function label(): string { return 'CockroachDB'; }
}
