Skip to content

docs: document boot-callback dialect override pattern for postgres-wire-compatible databases#85

Merged
markshust merged 2 commits into
developfrom
feature/pgsql-dialect-override-docs
May 26, 2026
Merged

docs: document boot-callback dialect override pattern for postgres-wire-compatible databases#85
markshust merged 2 commits into
developfrom
feature/pgsql-dialect-override-docs

Conversation

@markshust
Copy link
Copy Markdown
Collaborator

Summary

Closes #31 by proving and documenting that postgres-wire-compatible databases (CockroachDB, YugabyteDB, etc.) can ship as sibling packages depending on marko/database-pgsql and overriding only the 4 dialect-specific bindings via a boot callback — without splitting packages, renaming anything, or changing the framework.

Why this approach

packages/database-pgsql/module.php already exposes 5 separate bindings, and PgSqlConnection is dialect-clean (PDO + SET NAMES only). The architectural split the issue asks for is largely already done. The missing piece was a supported way for a downstream sibling package to override the dialect bindings without triggering BindingConflictException.

Investigation surfaced that Container::bind() is a direct write that bypasses BindingRegistry's conflict detection, and module boot callbacks run after all static bindings are registered. So a sibling dialect package can override the 4 dialect interfaces in its own module.php boot closure today — zero framework changes needed.

What's in this PR

  • Integration test (packages/database-pgsql/tests/Module/DialectOverrideTest.php) — proves a downstream module can override SqlGeneratorInterface, IntrospectorInterface, QueryBuilderInterface, and QueryBuilderFactoryInterface via boot while inheriting PgSqlConnection. Includes a regression guard asserting the pgsql manifest declares no singletons for the 4 dialect interfaces (since a cached singleton would defeat the override), and a loud-error guarantee that the static-bindings path throws BindingConflictException.
  • DI concept doc — new "Overriding another module's bindings" section in concepts/dependency-injection.md documents the generic pattern (applies to any sibling driver, not just database).
  • Database guide — new "Wire-compatible database variants" section in packages/database.md with a worked CockroachDB-style composer.json + module.php example.
  • Cross-link — short subsection on packages/database-pgsql.md pointing to the variants guide.

Test plan

  • composer test — 5282 tests pass (1 pre-existing unrelated failure in SplitWorkflowTest about SPLIT_TOKEN)
  • npm --prefix docs run build — clean, no warnings
  • ./vendor/bin/phpcs clean on touched files

Closes #31

🤖 Generated with Claude Code

Adds an integration test and documentation proving that postgres-wire-
compatible databases (CockroachDB, YugabyteDB, etc.) can ship as sibling
packages by depending on marko/database-pgsql and overriding the 4
dialect bindings via a boot callback — no package splits, no framework
changes.

- Integration test in packages/database-pgsql proves a downstream module
  can override SqlGenerator/Introspector/QueryBuilder/QueryBuilderFactory
  while inheriting PgSqlConnection, and confirms the static-bindings
  path correctly throws BindingConflictException.
- New "Overriding another module's bindings" section in the DI concept
  doc documents the generic pattern (applies to any sibling driver).
- New "Wire-compatible database variants" section in the database guide
  with a worked CockroachDB-style example.
- Cross-link from database-pgsql page to the database guide.

Closes #31

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added the documentation Improvements or additions to documentation label May 26, 2026
The marko/ vendor namespace is reserved for core Marko packages, so
variant driver packages must ship under their own vendor namespace.
Updates the worked CockroachDB example in database.md and the override
example in dependency-injection.md to use acme/database-cockroachdb
and Acme\Database\CockroachDb\ accordingly.

Also corrects the sequence.after example in dependency-injection.md to
use the composer package name format (marko/database-pgsql) rather than
a PHP class name, matching how sequence.after is actually parsed.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@markshust markshust merged commit f73ffd9 into develop May 26, 2026
@markshust markshust deleted the feature/pgsql-dialect-override-docs branch May 26, 2026 18:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

split database driver from dialect

1 participant