Skip to content

test: cover updateOrCreate primary-key aliases - #329

Open
elpete wants to merge 1 commit into
nextfrom
test/107-update-or-create-alias
Open

test: cover updateOrCreate primary-key aliases#329
elpete wants to merge 1 commit into
nextfrom
test/107-update-or-create-alias

Conversation

@elpete

@elpete elpete commented Aug 22, 2026

Copy link
Copy Markdown
Collaborator

Closes #107

Review

This is an essential Quick behavior: APIs that accept entity attributes must consistently resolve aliases to physical columns, especially for primary keys.

Recommendation: 10/10.

Reasons for

  • Entity consumers should not need to know physical database column names.
  • A missed alias in updateOrCreate can insert duplicates instead of updating.
  • Quick's configured qb column formatter is the correct central mechanism.
  • The regression is straightforward to verify through public APIs.

Reasons against

  • Supporting both aliases and physical columns can make ambiguous schemas harder to diagnose, though Quick already defines deterministic alias metadata.

Attempted reproduction

The repository already contains an issue-specific public test proving PostAlt.firstOrNew({ id: 1245 }) and firstOrNew({ post_pk: 1245 }) both find the same row. That behavior passes on current next with qb@14.0.0-beta.3.

I added the missing half of the report: PostAlt.updateOrCreate({ id: 1245 }, updates). It correctly resolves the id alias to the physical post_pk column, updates row 1245, and leaves exactly one matching record. The historical failure therefore no longer reproduces; this PR completes regression coverage.

Validation

  • Get and update specs: 39 passed, 0 failed, 0 errors
  • Full suite: 496 passed, 0 failed, 0 errors, 3 skipped
  • Formatter completed
  • git diff --check passed

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