Repository navigation
Hotfix/custom timestamps and builder soft deletes - #14
Merged
tabennett merged 6 commits intoNov 15, 2026
Merged
Conversation
storeEntity() excluded the timestamp columns from an update with self::, so a mapper that overrides CREATED_AT and UPDATED_AT had its created column included in every UPDATE with the entity's value, wiping the stored creation time when the entity didn't carry it. Exclude them with static:: like the rest of the method. Mappers with the default column names are unaffected. Add a fixture table, entity and mapper with custom timestamp columns, and tests for insert, update, and the UPDATE statement.
SoftDeletingScope called getDeletedAtColumn() on the mapper, which has never existed (the SoftDeletes trait defines getDeletedAtColumnName()), so where(...)->delete() and restore() on the builder always threw. The scope was ported from Eloquent, whose trait uses the other name. Also update through toBase() instead of the builder's __call fallback, which ran the raw query: it ignored global scopes, so rows that were already soft deleted would have been stamped again, and it returned the builder instead of the number of rows affected. Eloquent's scope relies on a real Builder::update() that does this; Holloway has none. Add tests for bulk soft delete, restore, the returned row counts, rows that are already deleted, and force delete.
Replace the warnings that these were unreliable. Note that they update in a single query, return the affected row count, don't fire persistence events, and stamp deleted_at with Carbon::now() rather than the mapper's currentTime().
Typing the relationship properties in 1e0f8d5 turned `protected $map;` into `protected ?Closure $map;`. An untyped property defaults to null, but a typed one is left uninitialized, so getMap() on a custom relationship that was given an entity class threw an Error instead of returning null, and getData() threw before the relationship had been loaded. The loader never calls either for those relationships, which is why nothing noticed. Default $map and $data on Custom and $data on BaseRelationship to null, the way $entityName already is. Also drop the docblock on Custom::__construct, which described $query as a QueryBuilder where it is a Closure, and the import it was the only user of.
The parameter is typed Scope|string, so once the string case is handled anything left is a Scope and the InvalidArgumentException for anything else could never be thrown.
Add tests for the builder's finders, or-where grouping inside global scopes, local scopes, simple and empty pagination, chunk and chunkById, macros and nested where closures; the Holloway registry; soft deleting entities with their events, force removal and restoring many at once; global scope registration and removal; custom relationships defined with callables and closures; mapper configuration accessors and non-incrementing inserts; the factory and the service provider. Line coverage goes from 67% to 98.5%. Also document that a bulk delete through a query fires no removal events. Fix the custom relationship in the PackMapper fixture, which assigned `$pack->id = $collar->pack_id` instead of comparing, so every pack was given every collar. The test that loads it onto many entities only checked the type of each collar, so assert how many each pack gets.
tabennett
deleted the
hotfix/custom-timestamps-and-builder-soft-deletes
branch
November 15, 2026 06:50
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.
No description provided.