classDrop
final class Drop
implements Statement
uses Snapshot
@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.
$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 SchemaObjectKind $objectpublic QualifiedName $namepublic bool $ifExists = falseMethods§
public function __construct(
public SchemaObjectKind $object,
public QualifiedName $name,
public bool $ifExists = false,
)Parameters
$object | SchemaObjectKind | The kind of object to remove |
$name | QualifiedName | The object name |
$ifExists | bool | Whether IF EXISTS is written |
Calls 1
- static-call Check::input() line 54
public function deriveStatement(Derivation $derivation): voidRecords the resolution of a dropped table or view.
Parameters
$derivation | Derivation |
Calls 12
- class-const SchemaObjectKind::Table() line 62
- class-const SchemaObjectKind::View() line 62
- method-call TableShapes::target() line 65
- new TableShapes line 65
- method-call RelationKinds::refuse() line 66
- new RelationKinds line 66
- class-const KindRefusal::DropView() line 66
- class-const KindRefusal::DropTable() line 66
- new RelationFact line 68
- new RowShape line 68
- new AbsentRelation line 68
- method-call Derivation::target() line 70
public function render(Output $out): voidWrites the request.
Parameters
$out | Output |
Calls 3
- method-call Output::keyword() line 78
- method-call ObjectNames::write() line 82
- new ObjectNames line 82
Test cases 4§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.