Skip to content

Bind IN lists as one parameter and allow mappings without a hydrator - #4

Merged
SoloPHP merged 2 commits into
mainfrom
rc3/package-gaps
Oct 25, 2026
Merged

SoloPHP merged 2 commits into
mainfrom
rc3/package-gaps

Conversation

@SoloPHP

@SoloPHP SoloPHP commented Oct 25, 2026 •

Copy link
Copy Markdown
Owner

Closes two package gaps that the dilio storefront found after moving to v1.0.0-RC2, before v1.0.0-RC3. Each commit covers one topic, with its tests, guides and changelog entry, and passes the checks on its own.

Changes

  • IN lists (7c711eb): IN/NOT IN criteria, the key lists of relation loads and lockForUpdate() bind one DBAL list parameter (ArrayParameterType) of values converted through the field type, instead of one named parameter per value. DBAL expands it into the same SQL when it runs the statement. Types without a DBAL list binding, such as boolean and large objects, still bind each value, and the parameter budget still counts every value of a list. COUNT(*) over id IN through the criteria bridge on SQLite drops from 1.30 to 0.53 ms for 1,000 ids and from 12.0 to 4.4 ms for 10,000 ids; one hand-written array parameter takes 0.45 and 3.6 ms.
  • Mappings without a hydrator (15cf0f2): the hydrate callback of a Mapping is optional, for tables read only as rows, such as link tables that no model represents. rows(), aggregates, queryBuilder(), related filters and writes work without one; find(), findOneBy(), findBy(), iterateById() and loading the mapping as a relation target throw LogicException before SQL. PHPStan infers such a mapping as Mapping<object>.

Behavior changes for RC2 users

  • A queryBuilder() with IN criteria holds a list parameter. Run the builder itself, or pass getParameterTypes() along with getParameters() when its SQL becomes part of another statement.
  • Mapping::$hydrate is nullable.

Verification

  • Final tree: 572 unit tests, PHPStan max and PSR-12 on PHP 8.3 and 8.5; the unit suite also passes with DBAL 4.3.5.
  • Integration suite on PostgreSQL 17, MySQL 8.4 and MariaDB 12.3: 31 tests, with DBAL 4.5.0 and 4.3.5, including typed IN lists of dates, decimals, strings and booleans and the full 65,535-value list.
  • The IN-list commit alone: 564 unit tests, PHPStan max, PSR-12 and the integration suite on all three servers.
  • The examples run.
  • The dilio storefront with this package in place of RC2: 266 tests pass, its PHPStan findings are unchanged, and 94 rendered pages are identical to RC2.

IN and NOT IN criteria, relation key lists and lockForUpdate() bound
one named parameter per value, so a long id list cost about three times
the PHP work of one array parameter. A list now holds its values
converted through the field type and binds as one ArrayParameterType
parameter, which DBAL expands into the same SQL when it runs the
statement. A type without a DBAL list binding, such as boolean, still
binds each value, and the parameter budget still counts every value of
a list.

SQL taken out of queryBuilder() into another statement now needs
getParameterTypes() along with getParameters().
A table read only through rows(), aggregates and queryBuilder(), such
as a link table that no model represents, still needed a hydrator and
a model class to build one. The hydrator is now optional and
Mapping::$hydrate is nullable. Rows, aggregates, queryBuilder(),
related filters and writes work without one, while reads that build
entities (find(), findOneBy(), findBy(), iterateById() and loading the
mapping as a relation target) throw a LogicException before SQL.
PHPStan infers such a mapping as Mapping<object>.
@SoloPHP
SoloPHP merged commit 3383800 into main Oct 25, 2026
26 checks passed
@SoloPHP
SoloPHP deleted the rc3/package-gaps branch October 27, 2026 21:46
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