Skip to content

Add table prefix support to TableIdentifier with configurable factory - #156

Merged
simon-mundy merged 11 commits into
php-db:0.6.xfrom
simon-mundy:issue-147
Aug 23, 2026
Merged

Add table prefix support to TableIdentifier with configurable factory#156
simon-mundy merged 11 commits into
php-db:0.6.xfrom
simon-mundy:issue-147

Conversation

@simon-mundy

Copy link
Copy Markdown
Member
Q A
Documentation yes/no
Bugfix yes/no
BC Break yes/no
New Feature yes/no
RFC yes/no
QA yes/no
House Keeping yes/no

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

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
@simon-mundy simon-mundy added this to the 0.6.0 milestone Jul 15, 2026
@simon-mundy
simon-mundy requested a review from tyrsson July 15, 2026 23:33
@simon-mundy simon-mundy self-assigned this Jul 15, 2026
@simon-mundy simon-mundy added the enhancement New feature or request label Jul 15, 2026
@simon-mundy simon-mundy added qa Improvements in quality assurance of the project next major Target next major release. labels Jul 15, 2026
@github-project-automation github-project-automation Bot moved this to Todo in @phpdb Jul 15, 2026
Comment thread src/ConfigProvider.php
Comment thread test/unit/Sql/TableIdentifierFactoryTest.php
Comment thread src/Sql/TableIdentifier.php
Comment thread src/Sql/TableIdentifier.php Outdated
Comment thread src/Sql/TableIdentifier.php Outdated
Comment thread src/Sql/TableIdentifier.php Outdated
Comment thread src/Container/TableIdentifierFactoryFactory.php Outdated
@github-project-automation github-project-automation Bot moved this from Todo to In Progress in @phpdb Jul 23, 2026
tyrsson
tyrsson previously approved these changes Jul 23, 2026
@tyrsson

tyrsson commented Aug 7, 2026

Copy link
Copy Markdown
Member

@simon-mundy where are we on this? I thought this had been merged.....

@tyrsson

tyrsson commented Aug 12, 2026

Copy link
Copy Markdown
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.

@tyrsson tyrsson left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to type the constants

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.
@codecov

codecov Bot commented Aug 23, 2026

Copy link
Copy Markdown

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
tyrsson self-requested a review August 23, 2026 16:43
@simon-mundy
simon-mundy merged commit f88f265 into php-db:0.6.x Aug 23, 2026
15 checks passed
@github-project-automation github-project-automation Bot moved this from In Progress to Done in @phpdb Aug 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request next major Target next major release. qa Improvements in quality assurance of the project

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[RFC]: Table / Schema Prefix Support

2 participants