Add table prefix support to TableIdentifier with configurable factory - #156
Merged
Conversation
Adds optional prefix and separator parameters to TableIdentifier. When a prefix is set, getTable() and getTableAndSchema() return the prefixed table name (prefix + separator + table), so the prefix flows through all SQL generation unchanged. The separator defaults to '_' and the original name remains available via getUnprefixedTable(). Adds the callable Sql\TableIdentifierFactory, which produces identifiers carrying a preconfigured prefix/separator, and the container factory Container\TableIdentifierFactoryFactory, which reads both from the 'config' service so the prefix can be set once globally (e.g. to create backup_* tables during a migration). Registered in ConfigProvider. Closes php-db#147
- Updated DDL documentation
Used separator CONST for Factory
Updated documentation
tyrsson
requested changes
Jul 23, 2026
tyrsson
previously approved these changes
Jul 23, 2026
Member
|
@simon-mundy where are we on this? I thought this had been merged..... |
Member
|
This one is approved but I would like to wait on merging it until the transition to the qa-tools is merged so it can be rebased against it. |
# Conflicts: # src/Sql/TableIdentifier.php # test/unit/Sql/TableIdentifierTest.php
Apply mago formatting to the new TableIdentifier factory classes and tests, declare the container and validation exceptions propagated by TableIdentifierFactoryFactory::__invoke(), and baseline the linter's prefer-test-attribute, assertion-style and literal-named-argument findings for the new test classes, matching the rest of the suite.
Aligns the caller workflow filename and display name with the convention used across the php-db org and prescribed by the phpdb-qa-tools README.
Turn on the qa-tools codecov and mutation-test jobs, which need secrets: inherit and a coverage-php-version to nominate the canonical matrix leg — without the latter no clover artifact is produced and both jobs break. Add infection/infection, infection.json5.dist and a mutation-test composer script. Infection 0.33+ requires PHP ^8.3, so dropping 8.2 is what allows 0.34.x; php constraints in composer.json, mago.toml, the CI matrix and the Docker deployment docs move with it. PHP 8.3 also permits typed class constants, so TableIdentifier::SEPARATOR gains one. min-msi and min-covered-msi are set to 80 against a measured baseline of 86% (2706 mutants, 100% mutation code coverage).
Infection 0.34 added 'mago' to StaticAnalysisToolTypes, so escaped mutants are now re-checked with mago analyze. resources/schema.json still lists only phpstan and debug, but the runtime enum is what validates the config.
Welcome to Codecov 🎉Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests. ℹ️ You can also turn on project coverage checks and project coverage reporting on Pull Request comment Thanks for integrating Codecov - We've got you covered ☂️ |
tyrsson
self-requested a review
August 23, 2026 16:43
tyrsson
approved these changes
Aug 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds optional prefix and separator parameters to TableIdentifier. When a prefix is set, getTable() and getTableAndSchema() return the prefixed table name (prefix + separator + table), so the prefix flows through all SQL generation unchanged. The separator defaults to '_' and the original name remains available via getUnprefixedTable().
Adds the callable Sql\TableIdentifierFactory, which produces identifiers carrying a preconfigured prefix/separator, and the container factory Container\TableIdentifierFactoryFactory, which reads both from the 'config' service so the prefix can be set once globally, registered in ConfigProvider.
Closes #147