Skip to content

fix: only treat @db.Uuid columns as UUIDs — drop field-name inference#39

Merged
samuelho-dev merged 1 commit into
mainfrom
fix/uuid-detection-no-name-inference-main
May 24, 2026
Merged

fix: only treat @db.Uuid columns as UUIDs — drop field-name inference#39
samuelho-dev merged 1 commit into
mainfrom
fix/uuid-detection-no-name-inference-main

Conversation

@samuelho-dev

@samuelho-dev samuelho-dev commented May 24, 2026

Copy link
Copy Markdown
Owner

Ports the UUID-detection fix (already merged to release/next as #37, published in 6.0.0-next.4) to the stable main line.

Problem

isUuidField had a third tier that inferred UUID from the field name (/^id$/, /_id$/, /^.*_uuid$/, /^uuid$/) for any String column. UUID is a column type, not a naming convention — the DMMF already knows the type. Every text identifier ending in _id (Stripe acct_/cus_/txn_/…, slugs, provider refs) got a spurious Schema.String.check(Schema.isUUID()) and Died at decode ("Expected a UUID, got acct_…").

Fix

Remove the name tier. isUuidField returns true only for @db.Uuid (native type or documentation) — which captures 100% of genuine UUID columns. Test + README + CLAUDE updated; changeset added (minor).

✅ 347 tests pass, typecheck + build clean.

Summary by CodeRabbit

  • Bug Fixes

    • UUID detection is now more accurate, only recognizing fields explicitly marked with @db.Uuid in Prisma. This removes false positives from field name inference that could cause issues with non-UUID text identifiers.
  • Documentation

    • Updated documentation on UUID field detection and how to explicitly mark UUID columns using @db.Uuid or custom type annotations.

Review Change Stack

isUuidField inferred UUID from field-name patterns (/^id$/, /_id$/, /_uuid$/,
/^uuid$/) for any String column. UUID is a column type, not a naming
convention: external text identifiers ending in _id (Stripe acct_/cus_/txn_…,
slugs, provider refs) were wrongly given Schema.isUUID() and Die'd at decode.
Prisma records real uuid columns via @db.Uuid (bare String → text), so the
native-type/@db.Uuid checks already capture every genuine UUID. Removed the
name-pattern tier; updated tests + docs.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@samuelho-dev samuelho-dev merged commit be1a22e into main May 24, 2026
2 of 6 checks passed
@coderabbitai

coderabbitai Bot commented May 24, 2026

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: c8dc14a0-f610-43d3-885d-a52e5146b8f1

📥 Commits

Reviewing files that changed from the base of the PR and between c965256 and 65bd59e.

📒 Files selected for processing (5)
  • .changeset/uuid-detection-no-name-inference.md
  • CLAUDE.md
  • README.md
  • src/__tests__/prisma-parsing.test.ts
  • src/prisma/type.ts

Disabled knowledge base sources:

  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.


📝 Walkthrough

Walkthrough

UUID detection in prisma-effect-kysely is simplified to rely exclusively on Prisma type information via @db.Uuid in native type or field documentation. Field-name pattern inference (id, _id, _uuid, uuid) is removed to eliminate false positives from external identifiers like Stripe IDs. Core logic, tests, and documentation are updated together.

Changes

UUID Detection Simplification

Layer / File(s) Summary
Core UUID detection logic
src/prisma/type.ts
isUuidField function now checks only field.nativeType[0] === 'Uuid' and field.documentation containing @db.Uuid; name-pattern fallback logic and String-type gating removed.
UUID detection test coverage
src/__tests__/prisma-parsing.test.ts
Test suite reworded to reflect authoritative @db.Uuid detection and replaced field-name-pattern test with explicit assertions that common naming conventions (_id, _uuid, id, uuid) do not trigger UUID inference.
Documentation and changelog
CLAUDE.md, README.md, .changeset/uuid-detection-no-name-inference.md
Internal dev guidance, user-facing README, and changeset documentation updated to define UUID detection as Prisma-type-only, remove name-pattern tier, and provide migration guidance via /// @db.Uuid`` or @customType(...) for explicit UUID marking.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/uuid-detection-no-name-inference-main

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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