Skip to content

feat: add entity replication - #350

Open
elpete wants to merge 1 commit into
nextfrom
issue/42
Open

feat: add entity replication#350
elpete wants to merge 1 commit into
nextfrom
issue/42

Conversation

@elpete

@elpete elpete commented Aug 22, 2026

Copy link
Copy Markdown
Collaborator

Closes #42

Issue review

Fit score: 9/10. Replicating a persisted record is a common ORM operation, and Quick already has nearly all the necessary primitives. A dedicated method is clearer and safer than cloning and manually clearing identity state.

Reasons for

  • concise public API for copy-as-new workflows
  • reliably removes single or composite primary keys
  • provides a lifecycle hook for adjusting replica defaults
  • optional exclusions avoid copying sensitive or unique attributes

Reasons against

  • relationships are intentionally not copied
  • unique fields still require caller or hook customization before save

Implementation

  • adds replicate( except = [] ) returning a new, unloaded entity
  • copies nulls while excluding all primary-key columns and caller exclusions
  • adds entity postReplicate and interceptor quickPostReplicate hooks with entity and original

Reproduction

Public-API tests first failed with QuickMissingMethod because replicate() did not exist; event tests also could not reach either requested hook.

Validation

  • focused clone/replication/event coverage: 8 passed, 0 failed, 0 errors
  • full suite: 499 passed, 0 failed, 0 errors, 3 skipped
  • box run-script format
  • git diff --check
  • qb dependency: 14.0.0-beta.3

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