classCreateView
final class CreateView
implements Statement
uses Snapshot
@visibility public.A request to create a view: a named query.
Rule: SQLITE-CREATE-VIEW-001. The query is derived as a root query. The statement provides one view declaration whose columns come from the output fields of the query, named by the column list when one is written (SQLITE-QUERY-COLUMNS-001). A view has no row identifier. A column list of another length than the query result is a diagnostic and leaves the declaration incomplete and its columns without types, as an open query shape without a column list leaves it incomplete; a name of the column list written with a collation or a sort order is a diagnostic. A TEMP view belongs to the temp schema. The statement returns no rows. Source: https://sqlite.org/lang_createview.html. Status: Implemented.
$view = (new \SqlSemantics\Platform\Sqlite\Semantics())->analyze('CREATE VIEW v (one, two) AS SELECT 1, 2');
[$view->declarations()[0]->columns[1]->name->value, $view->declarations()[0]->implicit] // => ['two', []]Properties§
public list<ListedColumn>|null $columnspublic QualifiedName $namepublic Query $querypublic bool $temporary = falsepublic bool $ifNotExists = falseMethods§
public function __construct(
public QualifiedName $name,
public Query $query,
list<ListedColumn>|null $columns = null,
public bool $temporary = false,
public bool $ifNotExists = false,
)Parameters
$name | QualifiedName | The view name |
$query | Query | The query the view stands for |
$columns | list<ListedColumn>|null | The column list; null when none is written, otherwise at least one |
$temporary | bool | Whether TEMP or TEMPORARY is written |
$ifNotExists | bool | Whether IF NOT EXISTS is written |
Calls 3
- static-call Check::input() line 67
- static-call Check::listOf() line 68
- class-const ListedColumn::class() line 68
public function deriveStatement(Derivation $derivation): voidDerives the query and provides the declaration made from its output.
Parameters
$derivation | Derivation |
Calls 16
- method-call TableProblems::temporary() line 76
- new TableProblems line 76
- method-call Derivation::report() line 81
- new DecoratedColumnName line 81
- method-call Derivation::query() line 85
- method-call Derivation::environment() line 85
- function-call
countline 86 - new ColumnCountMismatch line 89
- method-call QueryColumns::viewColumns() line 91
- new QueryColumns line 91
- method-call Derivation::facts() line 91
- method-call Derivation::declare() line 93
- new Table line 93
- method-call TableDeclaration::name() line 93
- new TableDeclaration line 93
- class-const RelationKind::View() line 93
public function render(Output $out): voidWrites the definition.
Parameters
$out | Output |
Calls 4
- method-call Output::keyword() line 101
- method-call ObjectNames::write() line 109
- new ObjectNames line 109
- method-call Output::symbol() line 111
Test cases 5§
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 4
CreateTableRuleTest::testCreatedAcceptsTheCreateKeywordOfEveryDefinitioncallsSchemaRuleTest::testCommandLowersEachSchemaCommandToItsOwnRequestcallsSchemaRuleTest::testViewKeepsTheHeaderFlagsAndTheOptionalColumnListcallsExplainTest::testDeriveStatementDiscardsTheRowsAndTheDeclarationOfTheInspectedStatementcalls