Repository navigation
Bind IN lists as one parameter and allow mappings without a hydrator - #4
Merged
Merged
Conversation
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>.
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.
Closes two package gaps that the dilio storefront found after moving to
v1.0.0-RC2, beforev1.0.0-RC3. Each commit covers one topic, with its tests, guides and changelog entry, and passes the checks on its own.Changes
7c711eb):IN/NOT INcriteria, the key lists of relation loads andlockForUpdate()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(*)overid INthrough 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.15cf0f2): thehydratecallback of aMappingis 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 throwLogicExceptionbefore SQL. PHPStan infers such a mapping asMapping<object>.Behavior changes for RC2 users
queryBuilder()with IN criteria holds a list parameter. Run the builder itself, or passgetParameterTypes()along withgetParameters()when its SQL becomes part of another statement.Mapping::$hydrateis nullable.Verification