Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(psl): add validation + warning on missing indexes for
relationMode = "prisma"
#3429feat(psl): add validation + warning on missing indexes for
relationMode = "prisma"
#3429Changes from 18 commits
01f1f2c
32b45c0
a188095
97ccc4d
2d40109
33e0912
f391f4b
109d558
84e891f
5701214
69c20c7
a312eb4
a78867e
2d25679
34e1b44
127c11b
3818edf
f1ddc0e
581b5ce
ecaf05e
a5a94d3
b747f6b
afc42aa
81267a3
6302434
cf302ba
eb283a1
98526a7
48312a4
c57c297
0832a54
873e328
4233793
258b019
d050fcd
52a204e
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should revisit the error message: "The fields referenced in a
@relation
should be indexed to prevent potential performance penalties." This will be a default error message for everyone switching from a normal schema to usingrelationMode=prisma
, and when writing a schema in relation modeprisma
.What do we really want to say here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
relationMode = "prisma"
, "@relation
attribute. This may have performance drawbacks and incur in more full-table scans than expected (e.g., implying higher bills on PlanetScale)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried something:
Note that using "reference" might be confusing, as we have a
references
property on@relation
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like that. Some iteration:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pinging @keerlu for ideas how to communicate this clearly. (also @Druue as she undersand the problem as well)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the
's
should be there, no? to indicate the possessive of@relation
@janpioThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then it would need to be "... so a/the @relation's fields will..." I think.
We call the whole thing "relation field", and
@relation
is the "relation attribute".So technically, we should probably refine a bit further even.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The 'will benefit' part reads oddly to me. I'd suggest something like:
Later part of text looks good to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In terms of referring to the relation, "
@relation
's field" definitely reads very oddly. "The@relation
's fields" is better but not great. Would it be an option to simply refer to "relation fields", rather than "@relation
fields"?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@keerlu I like your wording of
"""
With
relationMode="prisma", no foreign keys are used in your database, and so
@relation` fields will not be indexed automatically..."""
but this can also be misleading: not every relational database creates a backing index on
FOREIGN KEY
fields by default (e.g., Postgres doesn't). That's the reason previous sentence adopted "usually" in "SQL databases usually silently define an index..."There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is also useful for https://github.com/prisma/prisma-private/issues/198 and for #3435
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The highlighting is going to be on the field type, so only the
OtherModel
part inother OtherModel @relation(...)
. I think it would be more readable for users if we highlighted the whole field. Sorelation_field.ast_field().span
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I had a doubt about this span here. I think we mentioned elsewhere in the Notion doc that we wanted to highlight the
@relation
attribute.Hence, I'd propose the following
which falls back to your solution