Skip to content

v1.0.0-RC5

Pre-release
Pre-release

Choose a tag to compare

@SoloPHP SoloPHP released this 27 Oct 12:00
· 11 commits to main since this release
c774271

Fifth release candidate of Solo Repository (solophp/repository). It adds locking reads, ordering by the fields of related rows and native upserts — what the first application with 140 tables still wrote by hand.

This is a prerelease: the 1.0 API is being validated in real applications before the stable 1.0.0 tag.

Migrating from Base Repository v3: read the migration guide.

Changes since 1.0.0-RC4

  • ReadQuery::forUpdate() returns the same read as a locking one: find(), findOneBy(), findBy(), rows(), exists() and iterateById() run SELECT ... FOR UPDATE and lock the rows they read until the transaction ends, and throw LogicException outside a transaction. A locking read never answers from the snapshot of a REPEATABLE READ transaction: MySQL reads the latest committed row, while PostgreSQL and MariaDB reject a row changed since the snapshot as a serialization failure. PostgreSQL and MySQL 8 lock only the rows of the read's table (FOR UPDATE OF). See the read API.
  • orderBy accepts dotted paths through BelongsTo relations to a field of the target, such as category.name, in reads, default relation orders and Load orders. Each target is joined over the rows a load of the same relation in the read sees, so a list that shows soft-deleted rows through Visibility::All also orders by them.
  • Repository::upsert($key, $data, $onInsert = []) inserts the row of a unique key, or updates the row that already holds it, in one native statement. See Repository writes.
  • Behavior change: insertMany() runs a batch that fits one statement without a transaction or savepoint. Inside a caller's transaction on PostgreSQL, a failure of such a batch now aborts that transaction, as a failed insert() does.
  • Load and default relation orders accept the same paths, resolved when the read prepares its loads; an invalid order key reports "Order must use field names or relation paths to fields."

Install

composer require 'solophp/repository:^1.0@RC'

See the changelog for the full list of features and requirements, and the full diff since RC4.