Skip to content

Quick builder fixup - #179

Merged
mringler merged 2 commits into
perplorm:mainfrom
mringler:quick-builder-fixup
Nov 12, 2026
Merged

mringler merged 2 commits into
perplorm:mainfrom
mringler:quick-builder-fixup

Conversation

@mringler

@mringler mringler commented Nov 11, 2026 •

Copy link
Copy Markdown
Collaborator

Issue

QuickBuilder is used extensively during tests (and only there), but its methods does not reflect the current use case. I think this class was written for Propel1 and then with the introduction of the cli moved over into test-only usage.

Take for example the static buildSchema method:

     public static function buildSchema(
        string $schemaXml,
        ?string $dsn = null,
        ?string $user = null,
        ?string $pass = null,
        ?AdapterInterface $adapter = null,
        bool $vfs = true
    ): ConnectionWrapper {
        $builder = new self();
        $builder->setSchemaXml($schemaXml);
        $builder->setVfs($vfs);

        return $builder->build($dsn, $user, $pass, $adapter);
    }
  • we don't use spontaneous connections, so arguments 2 to 5 are never used
  • typically used properties (schema xml, platform, config) cannot be set via this shortcut but via tedious instance creation and setup
  • the name buildSchema insufficiently expresses that this will create DB tables and PHP classes (and not just one of those or even just schema parse result)

Changes

  • QuickBuilder gets a constructor, which allows to set schema xml, platform and config.
  • static methods buildDatabaseAndClasses(), buildClasses() now take platform and config, covering almost all use cases
  • tests are updated accordingly

Implementation Details

Turns out the QuickBuilder is frequently used during vendor-specific tests, however, unless properly configured, it builds for Sqlite. This isn't necessarily a bug, as there are tests that depend on a database connection and basic model hydration or such, but test vendor-independent functionality (like hooks injected by behaviors).
Previously, those tests couldn't be run as agnostic tests, since the available Sqlite connection was not registered. I assume the initial idea was that all db-dependent code should have to pass on all vendor dbs. However, as a result, those Sqlite tests ended up as vendor-specific tests. I find this very misleading - you think it tests on all databases, but the (i.e.) Postgres test is actually a Sqlite test too.
This is now changed, the agnostic tests can use the Sqlite connection. Let's see how that goes.

What is very confusing, the QuickBuilder sometimes uses a provided connection or, in lieu of that, a temporary Sqlite connection, and sometimes the connection associated with the database name as read from schema. Now the database name is consistently tried before falling back to the instant sqlite connection. But this is ultimately a step to the side.

Overall the "what am I building for" problem is a larger one, for another time. The main goal for now is to make QuickBuilder easier to use and a bit more opaque.

Test strategy

Tests itself.

Notes

There is more that could be done later.

I find it particularly confusing that there are three vendor specific type of classes (the adapter for runtime SQL generation, the platform for generator setup, and the parser to read the current schema from db), all three are used in the QuickBuilder, but since there is no way to set them together, it is often unclear which one is actually used.
When using a specific connection, the vendor-classes should be implied (and fixed).

@codecov

codecov Bot commented Nov 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@mringler
mringler force-pushed the quick-builder-fixup branch from 7cb33f6 to 724f442 Compare November 12, 2026 08:29
@mringler
mringler merged commit fdd4bda into perplorm:main Nov 12, 2026
83 checks passed
@mringler
mringler deleted the quick-builder-fixup branch November 12, 2026 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant