final class CteRows
Public API: explicitly declared with @visibility public.

Serializes arbitrary fixture rows through the public ValueRenderer contract into a table CTE.

Render a fixture table without accessing a databasedoctest
$rows = new \ZtdQuery\Platform\MySql\Rewrite\Transformer\Shadow\CteRows(
        new \ZtdQuery\Platform\MySql\Sql\Value\MySqlCastRenderer(),
        new \ZtdQuery\Platform\MySql\Rewrite\GeneratedColumn\MySqlGeneratedColumnProjector(),
        new \ZtdQuery\Platform\MySql\Sql\MySqlIdentifierQuoter(),
        new \ZtdQuery\Platform\MySql\Sql\Value\MySqlValueRenderer());
    $rows->generateCte('users', [['id' => 1]], ['id'], [], []) // => '`users` AS (SELECT CAST(1 AS SIGNED) AS `id`)'

Methods§

public function __construct(
    private CastRenderer $castRenderer,
    private MySqlGeneratedColumnProjector $generatedColumnProjector,
    private IdentifierQuoter $quoter,
    private ValueRenderer $valueRenderer,
)

Configure the dependencies used by this operation.

Parameters

$castRendererCastRenderer
$generatedColumnProjectorMySqlGeneratedColumnProjector
$quoterIdentifierQuoter
$valueRendererValueRenderer
public function generateCte(
    string $tableName,
    array<int, array<string, mixed>> $rows,
    array<int, string> $columns,
    array<string, ColumnDeclaration> $columnTypes,
    array<string, string> $generatedExpressions,
): string

Generate a CTE fragment for a single table.

Parameters

$tableNamestring
$rowsarray<int, array<string, mixed>>
$columnsarray<int, string>
$columnTypesarray<string, ColumnDeclaration>
$generatedExpressionsarray<string, string>

Returns

string

Throws

RuntimeException
Test cases 2
Called from 1
Calls 7
public function wrapCte(
    string $quotedTable,
    string $baseSql,
    array<int, string> $columns,
    array<string, string> $generatedExpressions,
): string
public function formatValue(mixed $val, ?ColumnDeclaration $type = null): string

Format Value for the supplied MySQL input.

Parameters

$valmixed
$type?ColumnDeclaration

Returns

string
Test cases 1
Called from 1
Calls 7
public function emptySelect(
    array<int, string> $columns,
    array<string, ColumnDeclaration> $columnTypes,
): string

Private surface 4§

Implementation details, listed for orientation only.

private CastRenderer $castRenderer
private MySqlGeneratedColumnProjector $generatedColumnProjector
private IdentifierQuoter $quoter
private ValueRenderer $valueRenderer

Test cases 16§

Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.

Dedicated tests 5
Other tests reaching this symbol 11

Relations§

Instantiated in 1
Method calls 1