final class Drop
    implements Statement
    uses Snapshot
Public API: explicitly declared with @visibility public.

A request to remove a table, a view, an index or a trigger.

Rule: SQLITE-DROP-001. The statement removes nothing from a context and provides no declaration. For a table or a view the name is resolved and the resolution is the relation fact of the statement node; a name a complete context does not declare is a diagnostic, unless IF EXISTS is written, in which case it is the resolution AbsentRelation. DROP TABLE of a declared view and DROP VIEW of a declared table are diagnostics, with or without IF EXISTS (SQLITE-RELATION-KIND-001). Indexes and triggers are not part of a declaration context; their names are kept unresolved. Source: https://sqlite.org/lang_droptable.html, https://sqlite.org/lang_dropview.html, https://sqlite.org/lang_dropindex.html, https://sqlite.org/lang_droptrigger.html. Status: Implemented.

Resolving the dropped table to its declarationdoctest
$semantics = new \SqlSemantics\Platform\Sqlite\Semantics();
    $table = $semantics->analyze('CREATE TABLE t (a)');
    $drop = $semantics->analyze('DROP TABLE IF EXISTS main.t', [$table]);
    [$drop->statement->ifExists, $drop->facts->relation($drop->statement)->table->table === $table->declarations()[0]] // => [true, true]

Properties§

public bool $ifExists = false

Methods§

public function __construct(
    public SchemaObjectKind $object,
    public QualifiedName $name,
    public bool $ifExists = false,
)

Parameters

$objectSchemaObjectKindThe kind of object to remove
$nameQualifiedNameThe object name
$ifExistsboolWhether IF EXISTS is written
Calls 1
public function deriveStatement(Derivation $derivation): void
public function render(Output $out): void

Writes the request.

Parameters

$outOutput
Calls 3

Test cases 4§

Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.

Dedicated tests 1
Other tests reaching this symbol 3

Relations§

Instantiated in 1