Skip to content

Fix field parsing in require-field-index#799

Merged
maxh merged 1 commit into
loop-payments:mainfrom
pedro:require-field-index-fix
Jan 15, 2026
Merged

Fix field parsing in require-field-index#799
maxh merged 1 commit into
loop-payments:mainfrom
pedro:require-field-index-fix

Conversation

@pedro

@pedro pedro commented Jan 5, 2026

Copy link
Copy Markdown
Contributor

Hi folks, thanks for this project!

Quick fix here - in my app require-field-index is throwing an error on models that have @@unique with a name followed by fields defined in an array, like:

model Foo {
  // ...
  @@unique(name: "some_unique_constraint", [field1, field2])
}

which results in:

    TypeError: Cannot read properties of undefined (reading 'value')

      222 |         return false;
      223 |       })?.value as KeyValue
    > 224 |     ).value;
          |       ^
      225 |
      226 |     if (fieldsValue == null) {
      227 |       throw new Error(

      at extractPrimaryFieldNameFromRelationListAttribute (src/rules/require-field-index.ts:224:7)
      at src/rules/require-field-index.ts:191:15

So adding a test and fixing the field parsing there.

@pedro pedro force-pushed the require-field-index-fix branch from f90c3d4 to dfdcccf Compare January 5, 2026 02:47
@pedro pedro force-pushed the require-field-index-fix branch from dfdcccf to 392267d Compare January 5, 2026 02:56

@maxh maxh left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks! i'll get this out shortly

@maxh maxh merged commit 48ee81a into loop-payments:main Jan 15, 2026
2 checks passed
maxh added a commit that referenced this pull request Jan 15, 2026
@maxh

maxh commented Jan 15, 2026

Copy link
Copy Markdown
Collaborator

@pedro try https://github.com/loop-payments/prisma-lint/releases/tag/v0.13.1 and lmk if any further issues!

@pedro

pedro commented Jan 16, 2026

Copy link
Copy Markdown
Contributor Author

Working nicely, thank you!

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