feat: close database layer gaps for 1.0#40
Merged
Conversation
Ten targeted hardenings across the database layer, query builder, and entity/repository surface: - String/UUID primary key support (int|string on find/findOrFail/exists) - Loud primary key validation (MissingPrimaryKeyException at metadata parse; removed silent 'id' column fallbacks) - Aggregate functions on QueryBuilder (min/max/sum/avg; count widened) - GROUP BY / HAVING on QueryBuilder - DISTINCT / UNION / UNION ALL on QueryBuilder (UnionShapeMismatchException on column-count mismatch) - Column aliasing in select() with a shared IdentifierValidator - insertBatch(Entity[]) with per-entity Creating/Created lifecycle events, single multi-row INSERT, MySQL lastInsertId+offset / PostgreSQL RETURNING - JSON column type (#[Column(type: 'json')]) with array / ?array support, JSON_THROW_ON_ERROR, JSONB on PostgreSQL; array-root-only scope is a permanent design boundary - EntityQueryBuilderInterface extends QueryBuilderInterface with with(); QuerySpecification::apply() widened to it so specs express eager loading fluently; fixed a pre-existing bug where matching() passed the raw inner builder - JSON query operators (whereJsonContains / whereJsonExists / whereJsonMissing) plus arrow-path syntax (data->user->name, data->>name) in where() and select(); MySQL JSON_EXTRACT/JSON_UNQUOTE/ JSON_CONTAINS/JSON_CONTAINS_PATH and PostgreSQL native -> / ->> / @> / jsonb_path_exists All public additions land on an interface first. Both marko/database-mysql and marko/database-pgsql drivers implement every new method in lockstep. Documentation updated in docs/src/content/docs/packages/ for database, database-mysql, and database-pgsql pages, plus a slimmed packages/database/README.md per the project docs standard. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Summary
Ten targeted hardenings to the database layer, query builder, and entity/repository surface — the last pass before 1.0.
int|stringacrossfind/findOrFail/exists/relationship loaders.MissingPrimaryKeyExceptionthrown at metadata-parse time — no more silent'id'fallback.min/max/sum/avgaggregates,count(?string)widened,GROUP BY/HAVING,DISTINCT,UNION/UNION ALL, column aliasing (COUNT(*) as total). SharedIdentifierValidatorroutes all dynamic identifier checks.insertBatch(Entity[])— single multi-row INSERT, per-entityCreating/Createdevents, MySQLlastInsertId + offset/ PostgreSQLRETURNING.#[Column(type: 'json')]witharray/?array, unlimited nesting. Full query operators:whereJsonContains,whereJsonExists,whereJsonMissing, arrow-path syntax (data->user->name,data->>name) inwhere()andselect(). MySQL (JSON_EXTRACT/JSON_UNQUOTE/JSON_CONTAINS/JSON_CONTAINS_PATH) and PostgreSQL (->/->>/@>/jsonb_path_exists). Array-root-only is a permanent design boundary.EntityQueryBuilderInterfacewidensQuerySpecification::apply()parameter. Specs now express eager loading fluently via$builder->with('author')insideapply(). Fixes pre-existing bug wherematching()passed the raw inner builder to specs.All public additions land on an interface first. Both
marko/database-mysqlandmarko/database-pgsqldrivers implement every new method in lockstep. Docs and package READMEs updated.Test plan
composer test(4816 passed, 0 failed)db-layer-1.0-gapsis merged before cutting 1.0composer test:allto include destructive integration tests before release cut🤖 Generated with Claude Code