Skip to content

Conversation

@pyramation
Copy link
Contributor

Summary

Ports a bug fix from constructive-db that modifies the field name uniqueness constraint to only apply name normalization (stripping _id, _uuid, _fk, _pk, _row_id suffixes) to UUID fields.

Previously, the constraint normalized ALL field names, which caused false collisions on text fields. For example, two legitimate text fields current_role and current_role_id would both normalize to current_role and conflict, even though they're different fields.

The fix adds a CASE WHEN type = 'uuid' check so normalization only applies to UUID fields (the actual FK candidates where this behavior is intended).

Review & Testing Checklist for Human

  • Verify the SQL syntax is correct and the CASE expression works as expected in PostgreSQL
  • Consider migration implications for existing databases that already have this index - may need a migration to drop and recreate the index
  • Run the metaschema-schema tests to ensure no regressions

Notes

This fix was originally made in constructive-db (commit b0dce8dd4) and is being upstreamed to this repo.

Link to Devin run: https://app.devin.ai/sessions/e768febe8d1f41f9b9b6c4bab0bc5d80
Requested by: Dan Lynch (@pyramation)

…elds

Only apply normalization (stripping _id, _uuid, etc. suffixes) to UUID fields
to avoid false collisions on text fields like current_role/current_role_id.

This fix was ported from constructive-db.
@devin-ai-integration
Copy link

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@pyramation pyramation merged commit 96392f0 into main Jan 7, 2026
42 of 43 checks passed
@pyramation pyramation deleted the devin/1767816713-fix-field-uniqueness-constraint branch January 7, 2026 20:35
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.

2 participants