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

1<?php
2
3declare(strict_types=1);
4
5namespace SqlSemantics\Statement\Model\PostgreSql\Value;
6
7/**
8 * The PLpgSQL_Expr 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\PLpgSqlExprWithOptDistinctClauseOptTargetListFromClauseWhereClauseGroupClauseHavingClauseW_ea473d71 $value): string => \SqlSemantics\Statement\Writer::render($value);
13 *     $write instanceof \Closure // => true
14 */
15final class PLpgSqlExprWithOptDistinctClauseOptTargetListFromClauseWhereClauseGroupClauseHavingClauseW_ea473d71 implements \SqlSemantics\Statement\Model\PostgreSql\Role\PLpgSqlExprForm
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\OptDistinctClauseForm $optDistinctClause,
24        public readonly \SqlSemantics\Statement\Model\PostgreSql\Role\OptTargetListForm $projections,
25        public readonly \SqlSemantics\Statement\Model\PostgreSql\Role\FromClauseForm $from,
26        public readonly \SqlSemantics\Statement\Model\PostgreSql\Role\WhereClauseForm $where,
27        public readonly \SqlSemantics\Statement\Model\PostgreSql\Role\GroupClauseForm $groupBy,
28        public readonly \SqlSemantics\Statement\Model\PostgreSql\Role\HavingClauseForm $having,
29        public readonly \SqlSemantics\Statement\Model\PostgreSql\Role\WindowClauseForm $windowClause,
30        public readonly \SqlSemantics\Statement\Model\PostgreSql\Role\OptSortClauseForm $optSortClause,
31        public readonly \SqlSemantics\Statement\Model\PostgreSql\Role\OptSelectLimitForm $optSelectLimit,
32        public readonly \SqlSemantics\Statement\Model\PostgreSql\Role\OptForLockingClauseForm $optForLockingClause,
33        public readonly \SqlSemantics\Statement\Comments $comments = new \SqlSemantics\Statement\Comments(),
34    ) {
35        $this->assert(\SqlSemantics\Statement\Model\PostgreSql\Contract\Contracts::contains($optDistinctClause), 'The optDistinctClause must be a generated immutable SQL value.');
36        $this->assert(\SqlSemantics\Statement\Model\PostgreSql\Contract\Contracts::contains($projections), 'The projections must be a generated immutable SQL value.');
37        $this->assert(\SqlSemantics\Statement\Model\PostgreSql\Contract\Contracts::contains($from), 'The from must be a generated immutable SQL value.');
38        $this->assert(\SqlSemantics\Statement\Model\PostgreSql\Contract\Contracts::contains($where), 'The where must be a generated immutable SQL value.');
39        $this->assert(\SqlSemantics\Statement\Model\PostgreSql\Contract\Contracts::contains($groupBy), 'The groupBy must be a generated immutable SQL value.');
40        $this->assert(\SqlSemantics\Statement\Model\PostgreSql\Contract\Contracts::contains($having), 'The having must be a generated immutable SQL value.');
41        $this->assert(\SqlSemantics\Statement\Model\PostgreSql\Contract\Contracts::contains($windowClause), 'The windowClause must be a generated immutable SQL value.');
42        $this->assert(\SqlSemantics\Statement\Model\PostgreSql\Contract\Contracts::contains($optSortClause), 'The optSortClause must be a generated immutable SQL value.');
43        $this->assert(\SqlSemantics\Statement\Model\PostgreSql\Contract\Contracts::contains($optSelectLimit), 'The optSelectLimit must be a generated immutable SQL value.');
44        $this->assert(\SqlSemantics\Statement\Model\PostgreSql\Contract\Contracts::contains($optForLockingClause), 'The optForLockingClause 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        $this->optDistinctClause->write($writer);
54        $writer->comments($this->comments, 1);
55        $this->projections->write($writer);
56        $writer->comments($this->comments, 2);
57        $this->from->write($writer);
58        $writer->comments($this->comments, 3);
59        $this->where->write($writer);
60        $writer->comments($this->comments, 4);
61        $this->groupBy->write($writer);
62        $writer->comments($this->comments, 5);
63        $this->having->write($writer);
64        $writer->comments($this->comments, 6);
65        $this->windowClause->write($writer);
66        $writer->comments($this->comments, 7);
67        $this->optSortClause->write($writer);
68        $writer->comments($this->comments, 8);
69        $this->optSelectLimit->write($writer);
70        $writer->comments($this->comments, 9);
71        $this->optForLockingClause->write($writer);
72    }
73
74    /**
75     * Returns a copy with a new optDistinctClause, preserving every other field.
76     */
77    public function withOptDistinctClause(\SqlSemantics\Statement\Model\PostgreSql\Role\OptDistinctClauseForm $optDistinctClause): self
78    {
79        return new self($optDistinctClause, $this->projections, $this->from, $this->where, $this->groupBy, $this->having, $this->windowClause, $this->optSortClause, $this->optSelectLimit, $this->optForLockingClause, $this->comments);
80    }
81
82    /**
83     * Returns a copy with a new projections, preserving every other field.
84     */
85    public function withProjections(\SqlSemantics\Statement\Model\PostgreSql\Role\OptTargetListForm $projections): self
86    {
87        return new self($this->optDistinctClause, $projections, $this->from, $this->where, $this->groupBy, $this->having, $this->windowClause, $this->optSortClause, $this->optSelectLimit, $this->optForLockingClause, $this->comments);
88    }
89
90    /**
91     * Returns a copy with a new from, preserving every other field.
92     */
93    public function withFrom(\SqlSemantics\Statement\Model\PostgreSql\Role\FromClauseForm $from): self
94    {
95        return new self($this->optDistinctClause, $this->projections, $from, $this->where, $this->groupBy, $this->having, $this->windowClause, $this->optSortClause, $this->optSelectLimit, $this->optForLockingClause, $this->comments);
96    }
97
98    /**
99     * Returns a copy with a new where, preserving every other field.
100     */
101    public function withWhere(\SqlSemantics\Statement\Model\PostgreSql\Role\WhereClauseForm $where): self
102    {
103        return new self($this->optDistinctClause, $this->projections, $this->from, $where, $this->groupBy, $this->having, $this->windowClause, $this->optSortClause, $this->optSelectLimit, $this->optForLockingClause, $this->comments);
104    }
105
106    /**
107     * Returns a copy with a new groupBy, preserving every other field.
108     */
109    public function withGroupBy(\SqlSemantics\Statement\Model\PostgreSql\Role\GroupClauseForm $groupBy): self
110    {
111        return new self($this->optDistinctClause, $this->projections, $this->from, $this->where, $groupBy, $this->having, $this->windowClause, $this->optSortClause, $this->optSelectLimit, $this->optForLockingClause, $this->comments);
112    }
113
114    /**
115     * Returns a copy with a new having, preserving every other field.
116     */
117    public function withHaving(\SqlSemantics\Statement\Model\PostgreSql\Role\HavingClauseForm $having): self
118    {
119        return new self($this->optDistinctClause, $this->projections, $this->from, $this->where, $this->groupBy, $having, $this->windowClause, $this->optSortClause, $this->optSelectLimit, $this->optForLockingClause, $this->comments);
120    }
121
122    /**
123     * Returns a copy with a new windowClause, preserving every other field.
124     */
125    public function withWindowClause(\SqlSemantics\Statement\Model\PostgreSql\Role\WindowClauseForm $windowClause): self
126    {
127        return new self($this->optDistinctClause, $this->projections, $this->from, $this->where, $this->groupBy, $this->having, $windowClause, $this->optSortClause, $this->optSelectLimit, $this->optForLockingClause, $this->comments);
128    }
129
130    /**
131     * Returns a copy with a new optSortClause, preserving every other field.
132     */
133    public function withOptSortClause(\SqlSemantics\Statement\Model\PostgreSql\Role\OptSortClauseForm $optSortClause): self
134    {
135        return new self($this->optDistinctClause, $this->projections, $this->from, $this->where, $this->groupBy, $this->having, $this->windowClause, $optSortClause, $this->optSelectLimit, $this->optForLockingClause, $this->comments);
136    }
137
138    /**
139     * Returns a copy with a new optSelectLimit, preserving every other field.
140     */
141    public function withOptSelectLimit(\SqlSemantics\Statement\Model\PostgreSql\Role\OptSelectLimitForm $optSelectLimit): self
142    {
143        return new self($this->optDistinctClause, $this->projections, $this->from, $this->where, $this->groupBy, $this->having, $this->windowClause, $this->optSortClause, $optSelectLimit, $this->optForLockingClause, $this->comments);
144    }
145
146    /**
147     * Returns a copy with a new optForLockingClause, preserving every other field.
148     */
149    public function withOptForLockingClause(\SqlSemantics\Statement\Model\PostgreSql\Role\OptForLockingClauseForm $optForLockingClause): self
150    {
151        return new self($this->optDistinctClause, $this->projections, $this->from, $this->where, $this->groupBy, $this->having, $this->windowClause, $this->optSortClause, $this->optSelectLimit, $optForLockingClause, $this->comments);
152    }
153
154    /**
155     * Returns a copy with a new comments, preserving every other field.
156     */
157    public function withComments(\SqlSemantics\Statement\Comments $comments): self
158    {
159        return new self($this->optDistinctClause, $this->projections, $this->from, $this->where, $this->groupBy, $this->having, $this->windowClause, $this->optSortClause, $this->optSelectLimit, $this->optForLockingClause, $comments);
160    }
161}
162