classTableContext
final class TableContext
Public API: explicitly declared with
@visibility public.Snapshots fixture values and schema metadata into the public transformer context contract.
$store = new \ZtdQuery\Shadow\ShadowStore();
$store->set('users', [['id' => 1]]);
$tableContext = new \ZtdQuery\Platform\MySql\Rewrite\Context\TableContext(
new \ZtdQuery\Platform\MySql\Rewrite\Cte\MySqlCteShadowComposer(),
new \ZtdQuery\Schema\TableDefinitionRegistry(),
$store,
new \ZtdQuery\Schema\ViewDefinitionSet());
$tableContext->buildTableContext()['users']['columns'] // => ['id']Methods§
public function __construct(
private MySqlCteShadowComposer $cteComposer,
private TableDefinitionRegistry $registry,
private ShadowStore $shadowStore,
private ViewDefinitionSet $views,
)Configure the dependencies used by this operation.
Parameters
$cteComposer | MySqlCteShadowComposer | |
$registry | TableDefinitionRegistry | |
$shadowStore | ShadowStore | |
$views | ViewDefinitionSet |
public function buildTableContext(): array<string, array{viewSql: string}|array{rows: array<int, array<string, mixed>>, columns: array<int, string>, columnTypes: array<string, ColumnDeclaration>, columnDefaults: array<string, string>, identityStrategies: array<string, IdentityGenerationStrategy>, generatedExpressions: array<string, string>, partitioning: TablePartitioning|null}>Build the table context map for transformers.
Returns
array<string, array{viewSql: string}|array{rows: array<int, array<string, mixed>>, columns: array<int, string>, columnTypes: array<string, ColumnDeclaration>, columnDefaults: array<string, string>, identityStrategies: array<string, IdentityGenerationStrategy>, generatedExpressions: array<string, string>, partitioning: TablePartitioning|null}>Test cases 1
Called from 1
Calls 7
- method-call ShadowStore::getAll() line 52
- method-call TableDefinitionRegistry::getAll() line 53
- method-call TableDefinitionRegistry::get() line 58
- function-call
array_keysline 61 - function-call
in_arrayline 64 - method-call MySqlViewShadowRenderer::render() line 85
- new MySqlViewShadowRenderer line 85
public function findUnknownTable(string $sql): ?stringFind Unknown Table for the supplied MySQL input.
Parameters
$sql | string |
Returns
?stringTest cases 1
Called from 1
Calls 6
- method-call MySqlSelectRelationParser::tableNames() line 100
- new MySqlSelectRelationParser line 100
- function-call
array_fill_keysline 101 - method-call MySqlCteShadowComposer::declaredCteNames() line 101
- function-call
strtolowerline 104 - method-call TableContext::tableExists() line 107
public function tableExists(string $tableName): boolTable Exists for the supplied MySQL input.
Parameters
$tableName | string |
Returns
boolTest cases 1
Called from 1
Calls 3
- method-call ShadowStore::has() line 120
- method-call TableDefinitionRegistry::has() line 124
- method-call ViewDefinitionSet::has() line 128
public function hasSchemaContext(): boolHas Schema Context for the supplied MySQL input.
Returns
boolTest cases 1
Called from 1
Calls 3
- method-call ShadowStore::getAll() line 140
- method-call TableDefinitionRegistry::hasAnyTables() line 144
- method-call ViewDefinitionSet::hasAnyViews() line 148
public function requireKnownTables(string $sql): voidReject references to unknown tables when the session has schema context.
Parameters
$sql | string |
Throws
Test cases 1
Called from 1
Calls 3
- method-call TableContext::hasSchemaContext() line 161
- method-call TableContext::findUnknownTable() line 162
- new UnknownSchemaException line 164
Private surface 4§
Implementation details, listed for orientation only.
private MySqlCteShadowComposer $cteComposerprivate TableDefinitionRegistry $registryprivate ShadowStore $shadowStoreprivate ViewDefinitionSet $viewsTest cases 8§
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 3
MySqlSessionFactoryTestcallsMySqlRewriterTestcallsStatementRewriterTestcalls