packages/sql-semantics-postgres/resources/models/Value/CreateStmtWithCreateOptTempTableQualifiedNameOptTableElementListOptInheritOptPartitionSpe_1026d012.php

1<?php
2
3declare(strict_types=1);
4
5namespace SqlSemantics\Statement\Model\PostgreSql\Value;
6
7/**
8 * The CreateStmt SQL value; generated by bin/build-models.php.
9 *
10 * @visibility public
11 * @example Accept a structured SQL value
12 *     $write = static fn (\SqlSemantics\Statement\Model\PostgreSql\Value\CreateStmtWithCreateOptTempTableQualifiedNameOptTableElementListOptInheritOptPartitionSpe_1026d012 $value): string => \SqlSemantics\Statement\Writer::render($value);
13 *     $write instanceof \Closure // => true
14 */
15final class CreateStmtWithCreateOptTempTableQualifiedNameOptTableElementListOptInheritOptPartitionSpe_1026d012 implements \SqlSemantics\Statement\Model\PostgreSql\Role\CreateStmtForm, \SqlSemantics\Statement\Model\PostgreSql\Role\ParseToplevelForm, \SqlSemantics\Statement\Model\PostgreSql\Role\RoutineBodyStmtForm, \SqlSemantics\Statement\Model\PostgreSql\Role\SchemaStmtForm, \SqlSemantics\Statement\Model\PostgreSql\Role\StmtForm, \SqlSemantics\Statement\Model\PostgreSql\Role\StmtmultiForm, \SqlSemantics\Statement\Model\PostgreSql\Role\ToplevelStmtForm, \SqlSemantics\Statement\Command
16{
17    use \SqlSemantics\Statement\Assertion;
18
19    /**
20     * Supplies the SQL values of this form; comments are kept by the position of the symbol each precedes.
21     */
22    public function __construct(
23        public readonly \SqlSemantics\Statement\Model\PostgreSql\Role\OptTempForm $optTemp,
24        public readonly \SqlSemantics\Statement\Model\PostgreSql\Role\QualifiedNameForm $qualifiedName,
25        public readonly \SqlSemantics\Statement\Model\PostgreSql\Role\OptTableElementListForm $optTableElementList,
26        public readonly \SqlSemantics\Statement\Model\PostgreSql\Role\OptInheritForm $optInherit,
27        public readonly \SqlSemantics\Statement\Model\PostgreSql\Role\OptPartitionSpecForm $optPartitionSpec,
28        public readonly \SqlSemantics\Statement\Model\PostgreSql\Role\TableAccessMethodClauseForm $tableAccessMethodClause,
29        public readonly \SqlSemantics\Statement\Model\PostgreSql\Role\OptWithForm $optWith,
30        public readonly \SqlSemantics\Statement\Model\PostgreSql\Role\OnCommitOptionForm $onCommitOption,
31        public readonly \SqlSemantics\Statement\Model\PostgreSql\Role\OptTableSpaceForm $optTableSpace,
32        public readonly \SqlSemantics\Statement\Comments $comments = new \SqlSemantics\Statement\Comments(),
33    ) {
34        $this->assert(\SqlSemantics\Statement\Model\PostgreSql\Contract\Contracts::contains($optTemp), 'The optTemp must be a generated immutable SQL value.');
35        $this->assert(\SqlSemantics\Statement\Model\PostgreSql\Contract\Contracts::contains($qualifiedName), 'The qualifiedName must be a generated immutable SQL value.');
36        $this->assert(\SqlSemantics\Statement\Model\PostgreSql\Contract\Contracts::contains($optTableElementList), 'The optTableElementList must be a generated immutable SQL value.');
37        $this->assert(\SqlSemantics\Statement\Model\PostgreSql\Contract\Contracts::contains($optInherit), 'The optInherit must be a generated immutable SQL value.');
38        $this->assert(\SqlSemantics\Statement\Model\PostgreSql\Contract\Contracts::contains($optPartitionSpec), 'The optPartitionSpec must be a generated immutable SQL value.');
39        $this->assert(\SqlSemantics\Statement\Model\PostgreSql\Contract\Contracts::contains($tableAccessMethodClause), 'The tableAccessMethodClause must be a generated immutable SQL value.');
40        $this->assert(\SqlSemantics\Statement\Model\PostgreSql\Contract\Contracts::contains($optWith), 'The optWith must be a generated immutable SQL value.');
41        $this->assert(\SqlSemantics\Statement\Model\PostgreSql\Contract\Contracts::contains($onCommitOption), 'The onCommitOption must be a generated immutable SQL value.');
42        $this->assert(\SqlSemantics\Statement\Model\PostgreSql\Contract\Contracts::contains($optTableSpace), 'The optTableSpace must be a generated immutable SQL value.');
43    }
44
45    /**
46     * Writes SQL entirely from this value's fields.
47     */
48    public function write(\SqlSemantics\Statement\Writer $writer): void
49    {
50        $writer->comments($this->comments, 0);
51        $writer->append('CREATE');
52        $writer->comments($this->comments, 1);
53        $this->optTemp->write($writer);
54        $writer->comments($this->comments, 2);
55        $writer->append('TABLE');
56        $writer->comments($this->comments, 3);
57        $this->qualifiedName->write($writer);
58        $writer->comments($this->comments, 4);
59        $writer->append('(');
60        $writer->comments($this->comments, 5);
61        $this->optTableElementList->write($writer);
62        $writer->comments($this->comments, 6);
63        $writer->append(')');
64        $writer->comments($this->comments, 7);
65        $this->optInherit->write($writer);
66        $writer->comments($this->comments, 8);
67        $this->optPartitionSpec->write($writer);
68        $writer->comments($this->comments, 9);
69        $this->tableAccessMethodClause->write($writer);
70        $writer->comments($this->comments, 10);
71        $this->optWith->write($writer);
72        $writer->comments($this->comments, 11);
73        $this->onCommitOption->write($writer);
74        $writer->comments($this->comments, 12);
75        $this->optTableSpace->write($writer);
76    }
77
78    /**
79     * Returns a copy with a new optTemp, preserving every other field.
80     */
81    public function withOptTemp(\SqlSemantics\Statement\Model\PostgreSql\Role\OptTempForm $optTemp): self
82    {
83        return new self($optTemp, $this->qualifiedName, $this->optTableElementList, $this->optInherit, $this->optPartitionSpec, $this->tableAccessMethodClause, $this->optWith, $this->onCommitOption, $this->optTableSpace, $this->comments);
84    }
85
86    /**
87     * Returns a copy with a new qualifiedName, preserving every other field.
88     */
89    public function withQualifiedName(\SqlSemantics\Statement\Model\PostgreSql\Role\QualifiedNameForm $qualifiedName): self
90    {
91        return new self($this->optTemp, $qualifiedName, $this->optTableElementList, $this->optInherit, $this->optPartitionSpec, $this->tableAccessMethodClause, $this->optWith, $this->onCommitOption, $this->optTableSpace, $this->comments);
92    }
93
94    /**
95     * Returns a copy with a new optTableElementList, preserving every other field.
96     */
97    public function withOptTableElementList(\SqlSemantics\Statement\Model\PostgreSql\Role\OptTableElementListForm $optTableElementList): self
98    {
99        return new self($this->optTemp, $this->qualifiedName, $optTableElementList, $this->optInherit, $this->optPartitionSpec, $this->tableAccessMethodClause, $this->optWith, $this->onCommitOption, $this->optTableSpace, $this->comments);
100    }
101
102    /**
103     * Returns a copy with a new optInherit, preserving every other field.
104     */
105    public function withOptInherit(\SqlSemantics\Statement\Model\PostgreSql\Role\OptInheritForm $optInherit): self
106    {
107        return new self($this->optTemp, $this->qualifiedName, $this->optTableElementList, $optInherit, $this->optPartitionSpec, $this->tableAccessMethodClause, $this->optWith, $this->onCommitOption, $this->optTableSpace, $this->comments);
108    }
109
110    /**
111     * Returns a copy with a new optPartitionSpec, preserving every other field.
112     */
113    public function withOptPartitionSpec(\SqlSemantics\Statement\Model\PostgreSql\Role\OptPartitionSpecForm $optPartitionSpec): self
114    {
115        return new self($this->optTemp, $this->qualifiedName, $this->optTableElementList, $this->optInherit, $optPartitionSpec, $this->tableAccessMethodClause, $this->optWith, $this->onCommitOption, $this->optTableSpace, $this->comments);
116    }
117
118    /**
119     * Returns a copy with a new tableAccessMethodClause, preserving every other field.
120     */
121    public function withTableAccessMethodClause(\SqlSemantics\Statement\Model\PostgreSql\Role\TableAccessMethodClauseForm $tableAccessMethodClause): self
122    {
123        return new self($this->optTemp, $this->qualifiedName, $this->optTableElementList, $this->optInherit, $this->optPartitionSpec, $tableAccessMethodClause, $this->optWith, $this->onCommitOption, $this->optTableSpace, $this->comments);
124    }
125
126    /**
127     * Returns a copy with a new optWith, preserving every other field.
128     */
129    public function withOptWith(\SqlSemantics\Statement\Model\PostgreSql\Role\OptWithForm $optWith): self
130    {
131        return new self($this->optTemp, $this->qualifiedName, $this->optTableElementList, $this->optInherit, $this->optPartitionSpec, $this->tableAccessMethodClause, $optWith, $this->onCommitOption, $this->optTableSpace, $this->comments);
132    }
133
134    /**
135     * Returns a copy with a new onCommitOption, preserving every other field.
136     */
137    public function withOnCommitOption(\SqlSemantics\Statement\Model\PostgreSql\Role\OnCommitOptionForm $onCommitOption): self
138    {
139        return new self($this->optTemp, $this->qualifiedName, $this->optTableElementList, $this->optInherit, $this->optPartitionSpec, $this->tableAccessMethodClause, $this->optWith, $onCommitOption, $this->optTableSpace, $this->comments);
140    }
141
142    /**
143     * Returns a copy with a new optTableSpace, preserving every other field.
144     */
145    public function withOptTableSpace(\SqlSemantics\Statement\Model\PostgreSql\Role\OptTableSpaceForm $optTableSpace): self
146    {
147        return new self($this->optTemp, $this->qualifiedName, $this->optTableElementList, $this->optInherit, $this->optPartitionSpec, $this->tableAccessMethodClause, $this->optWith, $this->onCommitOption, $optTableSpace, $this->comments);
148    }
149
150    /**
151     * Returns a copy with a new comments, preserving every other field.
152     */
153    public function withComments(\SqlSemantics\Statement\Comments $comments): self
154    {
155        return new self($this->optTemp, $this->qualifiedName, $this->optTableElementList, $this->optInherit, $this->optPartitionSpec, $this->tableAccessMethodClause, $this->optWith, $this->onCommitOption, $this->optTableSpace, $comments);
156    }
157}
158