packages/sql-semantics-mysql/src/Statement/Alter/AbsentTable.php
1<?php
2
3declare(strict_types=1);
4
5namespace SqlSemantics\Platform\MySql\Statement\Alter;
6
7use SqlSemantics\Platform\MySql\Model\Statement\Identifier\QualifiedName;
8use SqlSemantics\Platform\MySql\Model\Statement\Reference\Table\TableResolution;
9use SqlSemantics\Platform\MySql\Model\Statement\Snapshot;
10
11/**
12 * The resolution of a table name that a complete context does not declare and IF EXISTS allows to be absent.
13 *
14 * DROP TABLE IF EXISTS of such a table succeeds; the server only adds a
15 * note. It is not a diagnostic.
16 * Source: https://dev.mysql.com/doc/refman/8.4/en/drop-table.html.
17 *
18 * @visibility public
19 * @example Resolving an absent table that IF EXISTS allows
20 * $drop = (new \SqlSemantics\Platform\MySql\Semantics())->analyze('DROP TABLE IF EXISTS t', []);
21 * $drop->facts->relation($drop->statement->tables[0])->table instanceof \SqlSemantics\Platform\MySql\Statement\Alter\AbsentTable // => true
22 */
23final class AbsentTable implements TableResolution
24{
25 use Snapshot;
26
27 /**
28 * @param QualifiedName $name The name as the statement wrote it
29 */
30 public function __construct(public readonly QualifiedName $name)
31 {
32 }
33}
34