packages/sql-semantics-postgres/resources/models/Value/CreateStmtWithCreateOptTempTableIfPNotExistsQualifiedNameOptTableElementListOptInheritOpt_fa259f14.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\CreateStmtWithCreateOptTempTableIfPNotExistsQualifiedNameOptTableElementListOptInheritOpt_fa259f14 $value): string => \SqlSemantics\Statement\Writer::render($value);
13 * $write instanceof \Closure // => true
14 */
15final class CreateStmtWithCreateOptTempTableIfPNotExistsQualifiedNameOptTableElementListOptInheritOpt_fa259f14 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 $writer->append('IF');
58 $writer->comments($this->comments, 4);
59 $writer->append('NOT');
60 $writer->comments($this->comments, 5);
61 $writer->append('EXISTS');
62 $writer->comments($this->comments, 6);
63 $this->qualifiedName->write($writer);
64 $writer->comments($this->comments, 7);
65 $writer->append('(');
66 $writer->comments($this->comments, 8);
67 $this->optTableElementList->write($writer);
68 $writer->comments($this->comments, 9);
69 $writer->append(')');
70 $writer->comments($this->comments, 10);
71 $this->optInherit->write($writer);
72 $writer->comments($this->comments, 11);
73 $this->optPartitionSpec->write($writer);
74 $writer->comments($this->comments, 12);
75 $this->tableAccessMethodClause->write($writer);
76 $writer->comments($this->comments, 13);
77 $this->optWith->write($writer);
78 $writer->comments($this->comments, 14);
79 $this->onCommitOption->write($writer);
80 $writer->comments($this->comments, 15);
81 $this->optTableSpace->write($writer);
82 }
83
84 /**
85 * Returns a copy with a new optTemp, preserving every other field.
86 */
87 public function withOptTemp(\SqlSemantics\Statement\Model\PostgreSql\Role\OptTempForm $optTemp): self
88 {
89 return new self($optTemp, $this->qualifiedName, $this->optTableElementList, $this->optInherit, $this->optPartitionSpec, $this->tableAccessMethodClause, $this->optWith, $this->onCommitOption, $this->optTableSpace, $this->comments);
90 }
91
92 /**
93 * Returns a copy with a new qualifiedName, preserving every other field.
94 */
95 public function withQualifiedName(\SqlSemantics\Statement\Model\PostgreSql\Role\QualifiedNameForm $qualifiedName): self
96 {
97 return new self($this->optTemp, $qualifiedName, $this->optTableElementList, $this->optInherit, $this->optPartitionSpec, $this->tableAccessMethodClause, $this->optWith, $this->onCommitOption, $this->optTableSpace, $this->comments);
98 }
99
100 /**
101 * Returns a copy with a new optTableElementList, preserving every other field.
102 */
103 public function withOptTableElementList(\SqlSemantics\Statement\Model\PostgreSql\Role\OptTableElementListForm $optTableElementList): self
104 {
105 return new self($this->optTemp, $this->qualifiedName, $optTableElementList, $this->optInherit, $this->optPartitionSpec, $this->tableAccessMethodClause, $this->optWith, $this->onCommitOption, $this->optTableSpace, $this->comments);
106 }
107
108 /**
109 * Returns a copy with a new optInherit, preserving every other field.
110 */
111 public function withOptInherit(\SqlSemantics\Statement\Model\PostgreSql\Role\OptInheritForm $optInherit): self
112 {
113 return new self($this->optTemp, $this->qualifiedName, $this->optTableElementList, $optInherit, $this->optPartitionSpec, $this->tableAccessMethodClause, $this->optWith, $this->onCommitOption, $this->optTableSpace, $this->comments);
114 }
115
116 /**
117 * Returns a copy with a new optPartitionSpec, preserving every other field.
118 */
119 public function withOptPartitionSpec(\SqlSemantics\Statement\Model\PostgreSql\Role\OptPartitionSpecForm $optPartitionSpec): self
120 {
121 return new self($this->optTemp, $this->qualifiedName, $this->optTableElementList, $this->optInherit, $optPartitionSpec, $this->tableAccessMethodClause, $this->optWith, $this->onCommitOption, $this->optTableSpace, $this->comments);
122 }
123
124 /**
125 * Returns a copy with a new tableAccessMethodClause, preserving every other field.
126 */
127 public function withTableAccessMethodClause(\SqlSemantics\Statement\Model\PostgreSql\Role\TableAccessMethodClauseForm $tableAccessMethodClause): self
128 {
129 return new self($this->optTemp, $this->qualifiedName, $this->optTableElementList, $this->optInherit, $this->optPartitionSpec, $tableAccessMethodClause, $this->optWith, $this->onCommitOption, $this->optTableSpace, $this->comments);
130 }
131
132 /**
133 * Returns a copy with a new optWith, preserving every other field.
134 */
135 public function withOptWith(\SqlSemantics\Statement\Model\PostgreSql\Role\OptWithForm $optWith): self
136 {
137 return new self($this->optTemp, $this->qualifiedName, $this->optTableElementList, $this->optInherit, $this->optPartitionSpec, $this->tableAccessMethodClause, $optWith, $this->onCommitOption, $this->optTableSpace, $this->comments);
138 }
139
140 /**
141 * Returns a copy with a new onCommitOption, preserving every other field.
142 */
143 public function withOnCommitOption(\SqlSemantics\Statement\Model\PostgreSql\Role\OnCommitOptionForm $onCommitOption): self
144 {
145 return new self($this->optTemp, $this->qualifiedName, $this->optTableElementList, $this->optInherit, $this->optPartitionSpec, $this->tableAccessMethodClause, $this->optWith, $onCommitOption, $this->optTableSpace, $this->comments);
146 }
147
148 /**
149 * Returns a copy with a new optTableSpace, preserving every other field.
150 */
151 public function withOptTableSpace(\SqlSemantics\Statement\Model\PostgreSql\Role\OptTableSpaceForm $optTableSpace): self
152 {
153 return new self($this->optTemp, $this->qualifiedName, $this->optTableElementList, $this->optInherit, $this->optPartitionSpec, $this->tableAccessMethodClause, $this->optWith, $this->onCommitOption, $optTableSpace, $this->comments);
154 }
155
156 /**
157 * Returns a copy with a new comments, preserving every other field.
158 */
159 public function withComments(\SqlSemantics\Statement\Comments $comments): self
160 {
161 return new self($this->optTemp, $this->qualifiedName, $this->optTableElementList, $this->optInherit, $this->optPartitionSpec, $this->tableAccessMethodClause, $this->optWith, $this->onCommitOption, $this->optTableSpace, $comments);
162 }
163}
164