packages/sql-semantics-mysql/resources/models/Value/SingleMultiWithFromTableIdentOptUsePartitionWhereClauseOptOrderClauseDeleteLimitClause_59df5ae1.php
1<?php
2
3declare(strict_types=1);
4
5namespace SqlSemantics\Statement\Model\MySql\Value;
6
7/**
8 * The single_multi 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\MySql\Value\SingleMultiWithFromTableIdentOptUsePartitionWhereClauseOptOrderClauseDeleteLimitClause_59df5ae1 $value): string => \SqlSemantics\Statement\Writer::render($value);
13 * $write instanceof \Closure // => true
14 */
15final class SingleMultiWithFromTableIdentOptUsePartitionWhereClauseOptOrderClauseDeleteLimitClause_59df5ae1 implements \SqlSemantics\Statement\Model\MySql\Role\SingleMultiForm
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\MySql\Role\TableIdentForm $tableIdent,
24 public readonly \SqlSemantics\Statement\Model\MySql\Role\OptUsePartitionForm $optUsePartition,
25 public readonly \SqlSemantics\Statement\Model\MySql\Role\WhereClauseForm $where,
26 public readonly \SqlSemantics\Statement\Model\MySql\Role\OptOrderClauseForm $orderBy,
27 public readonly \SqlSemantics\Statement\Model\MySql\Role\DeleteLimitClauseForm $deleteLimitClause,
28 public readonly \SqlSemantics\Statement\Comments $comments = new \SqlSemantics\Statement\Comments(),
29 ) {
30 $this->assert(\SqlSemantics\Statement\Model\MySql\Contract\Contracts::contains($tableIdent), 'The tableIdent must be a generated immutable SQL value.');
31 $this->assert(\SqlSemantics\Statement\Model\MySql\Contract\Contracts::contains($optUsePartition), 'The optUsePartition must be a generated immutable SQL value.');
32 $this->assert(\SqlSemantics\Statement\Model\MySql\Contract\Contracts::contains($where), 'The where must be a generated immutable SQL value.');
33 $this->assert(\SqlSemantics\Statement\Model\MySql\Contract\Contracts::contains($orderBy), 'The orderBy must be a generated immutable SQL value.');
34 $this->assert(\SqlSemantics\Statement\Model\MySql\Contract\Contracts::contains($deleteLimitClause), 'The deleteLimitClause must be a generated immutable SQL value.');
35 }
36
37 /**
38 * Writes SQL entirely from this value's fields.
39 */
40 public function write(\SqlSemantics\Statement\Writer $writer): void
41 {
42 $writer->comments($this->comments, 0);
43 $writer->append('FROM');
44 $writer->comments($this->comments, 1);
45 $this->tableIdent->write($writer);
46 $writer->comments($this->comments, 2);
47 $this->optUsePartition->write($writer);
48 $writer->comments($this->comments, 3);
49 $this->where->write($writer);
50 $writer->comments($this->comments, 4);
51 $this->orderBy->write($writer);
52 $writer->comments($this->comments, 5);
53 $this->deleteLimitClause->write($writer);
54 }
55
56 /**
57 * Returns a copy with a new tableIdent, preserving every other field.
58 */
59 public function withTableIdent(\SqlSemantics\Statement\Model\MySql\Role\TableIdentForm $tableIdent): self
60 {
61 return new self($tableIdent, $this->optUsePartition, $this->where, $this->orderBy, $this->deleteLimitClause, $this->comments);
62 }
63
64 /**
65 * Returns a copy with a new optUsePartition, preserving every other field.
66 */
67 public function withOptUsePartition(\SqlSemantics\Statement\Model\MySql\Role\OptUsePartitionForm $optUsePartition): self
68 {
69 return new self($this->tableIdent, $optUsePartition, $this->where, $this->orderBy, $this->deleteLimitClause, $this->comments);
70 }
71
72 /**
73 * Returns a copy with a new where, preserving every other field.
74 */
75 public function withWhere(\SqlSemantics\Statement\Model\MySql\Role\WhereClauseForm $where): self
76 {
77 return new self($this->tableIdent, $this->optUsePartition, $where, $this->orderBy, $this->deleteLimitClause, $this->comments);
78 }
79
80 /**
81 * Returns a copy with a new orderBy, preserving every other field.
82 */
83 public function withOrderBy(\SqlSemantics\Statement\Model\MySql\Role\OptOrderClauseForm $orderBy): self
84 {
85 return new self($this->tableIdent, $this->optUsePartition, $this->where, $orderBy, $this->deleteLimitClause, $this->comments);
86 }
87
88 /**
89 * Returns a copy with a new deleteLimitClause, preserving every other field.
90 */
91 public function withDeleteLimitClause(\SqlSemantics\Statement\Model\MySql\Role\DeleteLimitClauseForm $deleteLimitClause): self
92 {
93 return new self($this->tableIdent, $this->optUsePartition, $this->where, $this->orderBy, $deleteLimitClause, $this->comments);
94 }
95
96 /**
97 * Returns a copy with a new comments, preserving every other field.
98 */
99 public function withComments(\SqlSemantics\Statement\Comments $comments): self
100 {
101 return new self($this->tableIdent, $this->optUsePartition, $this->where, $this->orderBy, $this->deleteLimitClause, $comments);
102 }
103}
104