packages/sql-semantics-sqlite/resources/models/Value/CmdWithWithInsertCmdIntoXfullnameIdlistOptSelectUpsert_8f9aafcd.php

1<?php
2
3declare(strict_types=1);
4
5namespace SqlSemantics\Statement\Model\Sqlite\Value;
6
7/**
8 * The cmd 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\Sqlite\Value\CmdWithWithInsertCmdIntoXfullnameIdlistOptSelectUpsert_8f9aafcd $value): string => \SqlSemantics\Statement\Writer::render($value);
13 *     $write instanceof \Closure // => true
14 */
15final class CmdWithWithInsertCmdIntoXfullnameIdlistOptSelectUpsert_8f9aafcd implements \SqlSemantics\Statement\Model\Sqlite\Role\CmdForm, \SqlSemantics\Statement\Model\Sqlite\Role\CmdxForm, \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\Sqlite\Role\WithForm $with,
24        public readonly \SqlSemantics\Statement\Model\Sqlite\Role\InsertCmdForm $insertCmd,
25        public readonly \SqlSemantics\Statement\Model\Sqlite\Role\XfullnameForm $xfullname,
26        public readonly \SqlSemantics\Statement\Model\Sqlite\Role\IdlistOptForm $idlistOpt,
27        public readonly \SqlSemantics\Statement\Model\Sqlite\Role\SelectForm $select,
28        public readonly \SqlSemantics\Statement\Model\Sqlite\Role\UpsertForm $upsert,
29        public readonly \SqlSemantics\Statement\Comments $comments = new \SqlSemantics\Statement\Comments(),
30    ) {
31        $this->assert(\SqlSemantics\Statement\Model\Sqlite\Contract\Contracts::contains($with), 'The with must be a generated immutable SQL value.');
32        $this->assert(\SqlSemantics\Statement\Model\Sqlite\Contract\Contracts::contains($insertCmd), 'The insertCmd must be a generated immutable SQL value.');
33        $this->assert(\SqlSemantics\Statement\Model\Sqlite\Contract\Contracts::contains($xfullname), 'The xfullname must be a generated immutable SQL value.');
34        $this->assert(\SqlSemantics\Statement\Model\Sqlite\Contract\Contracts::contains($idlistOpt), 'The idlistOpt must be a generated immutable SQL value.');
35        $this->assert(\SqlSemantics\Statement\Model\Sqlite\Contract\Contracts::contains($select), 'The select must be a generated immutable SQL value.');
36        $this->assert(\SqlSemantics\Statement\Model\Sqlite\Contract\Contracts::contains($upsert), 'The upsert must be a generated immutable SQL value.');
37    }
38
39    /**
40     * Writes SQL entirely from this value's fields.
41     */
42    public function write(\SqlSemantics\Statement\Writer $writer): void
43    {
44        $writer->comments($this->comments, 0);
45        $this->with->write($writer);
46        $writer->comments($this->comments, 1);
47        $this->insertCmd->write($writer);
48        $writer->comments($this->comments, 2);
49        $writer->append('INTO');
50        $writer->comments($this->comments, 3);
51        $this->xfullname->write($writer);
52        $writer->comments($this->comments, 4);
53        $this->idlistOpt->write($writer);
54        $writer->comments($this->comments, 5);
55        $this->select->write($writer);
56        $writer->comments($this->comments, 6);
57        $this->upsert->write($writer);
58    }
59
60    /**
61     * Returns a copy with a new with, preserving every other field.
62     */
63    public function withWith(\SqlSemantics\Statement\Model\Sqlite\Role\WithForm $with): self
64    {
65        return new self($with, $this->insertCmd, $this->xfullname, $this->idlistOpt, $this->select, $this->upsert, $this->comments);
66    }
67
68    /**
69     * Returns a copy with a new insertCmd, preserving every other field.
70     */
71    public function withInsertCmd(\SqlSemantics\Statement\Model\Sqlite\Role\InsertCmdForm $insertCmd): self
72    {
73        return new self($this->with, $insertCmd, $this->xfullname, $this->idlistOpt, $this->select, $this->upsert, $this->comments);
74    }
75
76    /**
77     * Returns a copy with a new xfullname, preserving every other field.
78     */
79    public function withXfullname(\SqlSemantics\Statement\Model\Sqlite\Role\XfullnameForm $xfullname): self
80    {
81        return new self($this->with, $this->insertCmd, $xfullname, $this->idlistOpt, $this->select, $this->upsert, $this->comments);
82    }
83
84    /**
85     * Returns a copy with a new idlistOpt, preserving every other field.
86     */
87    public function withIdlistOpt(\SqlSemantics\Statement\Model\Sqlite\Role\IdlistOptForm $idlistOpt): self
88    {
89        return new self($this->with, $this->insertCmd, $this->xfullname, $idlistOpt, $this->select, $this->upsert, $this->comments);
90    }
91
92    /**
93     * Returns a copy with a new select, preserving every other field.
94     */
95    public function withSelect(\SqlSemantics\Statement\Model\Sqlite\Role\SelectForm $select): self
96    {
97        return new self($this->with, $this->insertCmd, $this->xfullname, $this->idlistOpt, $select, $this->upsert, $this->comments);
98    }
99
100    /**
101     * Returns a copy with a new upsert, preserving every other field.
102     */
103    public function withUpsert(\SqlSemantics\Statement\Model\Sqlite\Role\UpsertForm $upsert): self
104    {
105        return new self($this->with, $this->insertCmd, $this->xfullname, $this->idlistOpt, $this->select, $upsert, $this->comments);
106    }
107
108    /**
109     * Returns a copy with a new comments, preserving every other field.
110     */
111    public function withComments(\SqlSemantics\Statement\Comments $comments): self
112    {
113        return new self($this->with, $this->insertCmd, $this->xfullname, $this->idlistOpt, $this->select, $this->upsert, $comments);
114    }
115}
116