packages/sql-semantics-mysql/src/Model/Statement/NamedRelation.php
1<?php
2
3declare(strict_types=1);
4
5namespace SqlSemantics\Platform\MySql\Model\Statement;
6
7use SqlSemantics\Platform\MySql\Model\Statement\Identifier\Name;
8use SqlSemantics\Platform\MySql\Model\Statement\Identifier\QualifiedName;
9
10/**
11 * An input relation that is one named table, view or common table, optionally renamed.
12 *
13 * @visibility public
14 * @example Reading the name of a named input
15 * $query = (new \SqlSemantics\Platform\MySql\Semantics())->analyze('SELECT a FROM t AS x');
16 * [$query->singleNamedInput()->name()->name->value, $query->singleNamedInput()->alias()?->value] // => ['t', 'x']
17 */
18interface NamedRelation extends Relation
19{
20 /**
21 * Answers the relation name as the statement wrote it, decoded.
22 */
23 public function name(): QualifiedName;
24
25 /**
26 * Answers the correlation name that renames the occurrence, when one is given.
27 */
28 public function alias(): ?Name;
29}
30