Skip to content

fix(soft-delete): make softDelete() callable with a typed db client - #104

Merged
PAMulligan merged 1 commit into
mainfrom
53-add-soft-delete-middleware-and-drizzle-query-filters
Jun 7, 2026
Merged

fix(soft-delete): make softDelete() callable with a typed db client#104
PAMulligan merged 1 commit into
mainfrom
53-add-soft-delete-middleware-and-drizzle-query-filters

Conversation

@PAMulligan

@PAMulligan PAMulligan commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

What changed

softDelete() (added in #103) typed its db parameter as PgDatabase<PgQueryResultHKT>, which pins the schema generics to their Record<string, never> defaults. That schema generic is invariant, so passing a real schema-typed Drizzle client (e.g. PostgresJsDatabase<typeof schema>) fails to compile with TS2379. The documented await softDelete(db, table, id) pattern therefore couldn't actually be used in a generated project.

This PR:

  1. Widens softDelete()'s generics to infer the query-result and schema types, so it accepts any concrete Drizzle client. Backward-compatible — broadening a constraint never breaks existing callers.
  2. Adds templates/snippets/node/src/routes/users.ts — a typechecked Hono route that actually invokes softDelete(), softDeleteFilter(), and includeDeletedQuerySchema against the real db. The typecheck suite now exercises a live soft-delete call, so this regression can't silently return.

Context

The soft-delete feature for issue #53 (schema column, query filters, softDelete, ?include_deleted, skill docs, tests) already landed in #103. This PR was originally opened in parallel as a duplicate; it has been rescoped down to the one genuine gap that work left behind — the helper wasn't callable with a typed client, and nothing in the typecheck suite invoked it.

Refs #53. Complements #103.

🤖 Generated with Claude Code

@PAMulligan PAMulligan linked an issue Jun 1, 2026 that may be closed by this pull request
8 tasks
@github-actions github-actions Bot added area: skills Claude Code skills area: templates Starter templates labels Jun 1, 2026
softDelete()'s `db` parameter was typed `PgDatabase<PgQueryResultHKT>`,
which pins the schema generics to their `Record<string, never>` defaults.
Because that schema generic is invariant, passing a real, schema-typed
Drizzle client (e.g. `PostgresJsDatabase<typeof schema>`) fails to compile
with TS2379 — so the documented `await softDelete(db, table, id)` pattern
could not actually be used in a generated project.

Widen the signature to infer the query-result and schema generics, which
accepts any concrete Drizzle client while staying fully backward compatible
(broadening a constraint never breaks existing callers).

Add templates/snippets/node/src/routes/users.ts: a typechecked Hono route
that exercises softDelete(), softDeleteFilter(), and includeDeletedQuerySchema
against the real db client, so the typecheck suite now covers an actual
soft-delete invocation and this regression cannot return unnoticed.

Refs #53 (soft-delete feature landed in #103).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@PAMulligan
PAMulligan force-pushed the 53-add-soft-delete-middleware-and-drizzle-query-filters branch from c070dac to 8b807ae Compare June 7, 2026 02:03
@PAMulligan PAMulligan changed the title feat(database-design): add soft-delete query filters and helpers fix(soft-delete): make softDelete() callable with a typed db client Jun 7, 2026
@github-actions github-actions Bot removed the area: skills Claude Code skills label Jun 7, 2026
@PAMulligan
PAMulligan merged commit 18e894f into main Jun 7, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: templates Starter templates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add soft delete middleware and Drizzle query filters

1 participant