packages/sql-semantics-postgres/resources/models/Value/CopyStmtWithCopyOptBinaryQualifiedNameOptColumnListCopyFromOptProgramCopyFileNameCopyDe_2b21c137.php
1<?php
2
3declare(strict_types=1);
4
5namespace SqlSemantics\Statement\Model\PostgreSql\Value;
6
7/**
8 * The CopyStmt 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\CopyStmtWithCopyOptBinaryQualifiedNameOptColumnListCopyFromOptProgramCopyFileNameCopyDe_2b21c137 $value): string => \SqlSemantics\Statement\Writer::render($value);
13 * $write instanceof \Closure // => true
14 */
15final class CopyStmtWithCopyOptBinaryQualifiedNameOptColumnListCopyFromOptProgramCopyFileNameCopyDe_2b21c137 implements \SqlSemantics\Statement\Model\PostgreSql\Role\CopyStmtForm, \SqlSemantics\Statement\Model\PostgreSql\Role\ParseToplevelForm, \SqlSemantics\Statement\Model\PostgreSql\Role\RoutineBodyStmtForm, \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\OptBinaryForm $optBinary,
24 public readonly \SqlSemantics\Statement\Model\PostgreSql\Role\QualifiedNameForm $qualifiedName,
25 public readonly \SqlSemantics\Statement\Model\PostgreSql\Role\OptColumnListForm $optColumnList,
26 public readonly \SqlSemantics\Statement\Model\PostgreSql\Role\CopyFromForm $copyFrom,
27 public readonly \SqlSemantics\Statement\Model\PostgreSql\Role\OptProgramForm $optProgram,
28 public readonly \SqlSemantics\Statement\Model\PostgreSql\Role\CopyFileNameForm $copyFileName,
29 public readonly \SqlSemantics\Statement\Model\PostgreSql\Role\CopyDelimiterForm $copyDelimiter,
30 public readonly \SqlSemantics\Statement\Model\PostgreSql\Role\OptWithForm $optWith,
31 public readonly \SqlSemantics\Statement\Model\PostgreSql\Role\CopyOptionsForm $copyOptions,
32 public readonly \SqlSemantics\Statement\Model\PostgreSql\Role\WhereClauseForm $where,
33 public readonly \SqlSemantics\Statement\Comments $comments = new \SqlSemantics\Statement\Comments(),
34 ) {
35 $this->assert(\SqlSemantics\Statement\Model\PostgreSql\Contract\Contracts::contains($optBinary), 'The optBinary must be a generated immutable SQL value.');
36 $this->assert(\SqlSemantics\Statement\Model\PostgreSql\Contract\Contracts::contains($qualifiedName), 'The qualifiedName must be a generated immutable SQL value.');
37 $this->assert(\SqlSemantics\Statement\Model\PostgreSql\Contract\Contracts::contains($optColumnList), 'The optColumnList must be a generated immutable SQL value.');
38 $this->assert(\SqlSemantics\Statement\Model\PostgreSql\Contract\Contracts::contains($copyFrom), 'The copyFrom must be a generated immutable SQL value.');
39 $this->assert(\SqlSemantics\Statement\Model\PostgreSql\Contract\Contracts::contains($optProgram), 'The optProgram must be a generated immutable SQL value.');
40 $this->assert(\SqlSemantics\Statement\Model\PostgreSql\Contract\Contracts::contains($copyFileName), 'The copyFileName must be a generated immutable SQL value.');
41 $this->assert(\SqlSemantics\Statement\Model\PostgreSql\Contract\Contracts::contains($copyDelimiter), 'The copyDelimiter must be a generated immutable SQL value.');
42 $this->assert(\SqlSemantics\Statement\Model\PostgreSql\Contract\Contracts::contains($optWith), 'The optWith must be a generated immutable SQL value.');
43 $this->assert(\SqlSemantics\Statement\Model\PostgreSql\Contract\Contracts::contains($copyOptions), 'The copyOptions must be a generated immutable SQL value.');
44 $this->assert(\SqlSemantics\Statement\Model\PostgreSql\Contract\Contracts::contains($where), 'The where must be a generated immutable SQL value.');
45 }
46
47 /**
48 * Writes SQL entirely from this value's fields.
49 */
50 public function write(\SqlSemantics\Statement\Writer $writer): void
51 {
52 $writer->comments($this->comments, 0);
53 $writer->append('COPY');
54 $writer->comments($this->comments, 1);
55 $this->optBinary->write($writer);
56 $writer->comments($this->comments, 2);
57 $this->qualifiedName->write($writer);
58 $writer->comments($this->comments, 3);
59 $this->optColumnList->write($writer);
60 $writer->comments($this->comments, 4);
61 $this->copyFrom->write($writer);
62 $writer->comments($this->comments, 5);
63 $this->optProgram->write($writer);
64 $writer->comments($this->comments, 6);
65 $this->copyFileName->write($writer);
66 $writer->comments($this->comments, 7);
67 $this->copyDelimiter->write($writer);
68 $writer->comments($this->comments, 8);
69 $this->optWith->write($writer);
70 $writer->comments($this->comments, 9);
71 $this->copyOptions->write($writer);
72 $writer->comments($this->comments, 10);
73 $this->where->write($writer);
74 }
75
76 /**
77 * Returns a copy with a new optBinary, preserving every other field.
78 */
79 public function withOptBinary(\SqlSemantics\Statement\Model\PostgreSql\Role\OptBinaryForm $optBinary): self
80 {
81 return new self($optBinary, $this->qualifiedName, $this->optColumnList, $this->copyFrom, $this->optProgram, $this->copyFileName, $this->copyDelimiter, $this->optWith, $this->copyOptions, $this->where, $this->comments);
82 }
83
84 /**
85 * Returns a copy with a new qualifiedName, preserving every other field.
86 */
87 public function withQualifiedName(\SqlSemantics\Statement\Model\PostgreSql\Role\QualifiedNameForm $qualifiedName): self
88 {
89 return new self($this->optBinary, $qualifiedName, $this->optColumnList, $this->copyFrom, $this->optProgram, $this->copyFileName, $this->copyDelimiter, $this->optWith, $this->copyOptions, $this->where, $this->comments);
90 }
91
92 /**
93 * Returns a copy with a new optColumnList, preserving every other field.
94 */
95 public function withOptColumnList(\SqlSemantics\Statement\Model\PostgreSql\Role\OptColumnListForm $optColumnList): self
96 {
97 return new self($this->optBinary, $this->qualifiedName, $optColumnList, $this->copyFrom, $this->optProgram, $this->copyFileName, $this->copyDelimiter, $this->optWith, $this->copyOptions, $this->where, $this->comments);
98 }
99
100 /**
101 * Returns a copy with a new copyFrom, preserving every other field.
102 */
103 public function withCopyFrom(\SqlSemantics\Statement\Model\PostgreSql\Role\CopyFromForm $copyFrom): self
104 {
105 return new self($this->optBinary, $this->qualifiedName, $this->optColumnList, $copyFrom, $this->optProgram, $this->copyFileName, $this->copyDelimiter, $this->optWith, $this->copyOptions, $this->where, $this->comments);
106 }
107
108 /**
109 * Returns a copy with a new optProgram, preserving every other field.
110 */
111 public function withOptProgram(\SqlSemantics\Statement\Model\PostgreSql\Role\OptProgramForm $optProgram): self
112 {
113 return new self($this->optBinary, $this->qualifiedName, $this->optColumnList, $this->copyFrom, $optProgram, $this->copyFileName, $this->copyDelimiter, $this->optWith, $this->copyOptions, $this->where, $this->comments);
114 }
115
116 /**
117 * Returns a copy with a new copyFileName, preserving every other field.
118 */
119 public function withCopyFileName(\SqlSemantics\Statement\Model\PostgreSql\Role\CopyFileNameForm $copyFileName): self
120 {
121 return new self($this->optBinary, $this->qualifiedName, $this->optColumnList, $this->copyFrom, $this->optProgram, $copyFileName, $this->copyDelimiter, $this->optWith, $this->copyOptions, $this->where, $this->comments);
122 }
123
124 /**
125 * Returns a copy with a new copyDelimiter, preserving every other field.
126 */
127 public function withCopyDelimiter(\SqlSemantics\Statement\Model\PostgreSql\Role\CopyDelimiterForm $copyDelimiter): self
128 {
129 return new self($this->optBinary, $this->qualifiedName, $this->optColumnList, $this->copyFrom, $this->optProgram, $this->copyFileName, $copyDelimiter, $this->optWith, $this->copyOptions, $this->where, $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->optBinary, $this->qualifiedName, $this->optColumnList, $this->copyFrom, $this->optProgram, $this->copyFileName, $this->copyDelimiter, $optWith, $this->copyOptions, $this->where, $this->comments);
138 }
139
140 /**
141 * Returns a copy with a new copyOptions, preserving every other field.
142 */
143 public function withCopyOptions(\SqlSemantics\Statement\Model\PostgreSql\Role\CopyOptionsForm $copyOptions): self
144 {
145 return new self($this->optBinary, $this->qualifiedName, $this->optColumnList, $this->copyFrom, $this->optProgram, $this->copyFileName, $this->copyDelimiter, $this->optWith, $copyOptions, $this->where, $this->comments);
146 }
147
148 /**
149 * Returns a copy with a new where, preserving every other field.
150 */
151 public function withWhere(\SqlSemantics\Statement\Model\PostgreSql\Role\WhereClauseForm $where): self
152 {
153 return new self($this->optBinary, $this->qualifiedName, $this->optColumnList, $this->copyFrom, $this->optProgram, $this->copyFileName, $this->copyDelimiter, $this->optWith, $this->copyOptions, $where, $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->optBinary, $this->qualifiedName, $this->optColumnList, $this->copyFrom, $this->optProgram, $this->copyFileName, $this->copyDelimiter, $this->optWith, $this->copyOptions, $this->where, $comments);
162 }
163}
164