Skip to content
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

Autocomplete does not work for arguments after the first one in @relation() #814

Closed
tomhoule opened this issue Jun 28, 2021 · 6 comments · Fixed by #840
Closed

Autocomplete does not work for arguments after the first one in @relation() #814

tomhoule opened this issue Jun 28, 2021 · 6 comments · Fixed by #840
Assignees
Labels
bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. kind/bug A reported bug. team/schema Issue for team Schema. topic: autocompletion topic: referentialActions
Milestone

Comments

@tomhoule
Copy link
Contributor

Bug description

When authoring a schema in VSCode with the extension, if onDelete or onUpdate is the first argument in an @relation, autocomplete for referential actions works, but when it comes after another argument, it doesn't and reverts to the buffer word completion.

image

How to reproduce

Expected behavior

Autocomplete works in that position.

Prisma information

Using a recent version of prisma-fmt (e6bd3dc12d849124a04c3a8e6bd9c194381afda3)

Environment & setup

  • OS:
  • Editor: VSCode
  • Editor version:
  • Extension version: e6bd3dc12d849124a04c3a8e6bd9c194381afda3
@tomhoule tomhoule added bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. kind/bug A reported bug. labels Jun 28, 2021
@Jolg42 Jolg42 added process/candidate Candidate for next Milestone. team/schema Issue for team Schema. labels Jun 28, 2021
@pimeys
Copy link
Contributor

pimeys commented Jun 30, 2021

It's not directly related to referential actions. Even with the previous version, if you had fields as the first property, then no autocompletion would work on the second.

@janpio
Copy link
Member

janpio commented Jun 30, 2021

This test probably needs to be expanded/duplicated to also test when there are already one or some properties in @relation, to confirm auto completion is triggered:

const relationDirectiveUri = 'completions/relationDirective.prisma'
test('Diagnoses arguments of @relation directive', () => {
assertCompletion(
relationDirectiveUri,
{ line: 12, character: 26 },
{
isIncomplete: false,
items: [referencesProperty, fieldsProperty, onDeleteProperty, onUpdateProperty, nameProperty],
},
)
assertCompletion(
relationDirectiveUri,
{ line: 21, character: 39 },
{
isIncomplete: false,
items: [
{ label: 'id', kind: CompletionItemKind.Field },
{ label: 'items', kind: CompletionItemKind.Field },
{ label: 'total', kind: CompletionItemKind.Field },
],
},
)
assertCompletion(
relationDirectiveUri,
{ line: 30, character: 44 },
{
isIncomplete: false,
items: [fieldsProperty, onDeleteProperty, onUpdateProperty, nameProperty],
},
)
assertCompletion(
relationDirectiveUri,
{ line: 39, character: 45 },
{
isIncomplete: false,
items: [referencesProperty, onDeleteProperty, onUpdateProperty, nameProperty],
},
)
assertCompletion(
relationDirectiveUri,
{ line: 48, character: 35 },
{
isIncomplete: false,
items: [
{ label: 'id', kind: CompletionItemKind.Field },
{ label: 'productName', kind: CompletionItemKind.Field },
{ label: 'productPrice', kind: CompletionItemKind.Field },
{ label: 'quantity', kind: CompletionItemKind.Field },
{ label: 'orderId', kind: CompletionItemKind.Field },
],
},
)
})

This might also affect other auto completions than @relation, if they have multiple possible attributes (not sure if we have any).

@tomhoule
Copy link
Contributor Author

@@index and @@unique are going to take multiple arguments after we merge the constraint names work.

@janpio
Copy link
Member

janpio commented Jul 1, 2021

I created a PR that adds some tests, that I think would test for what you can see above in the screenshot: #820
Tests are indeed failing.

@janpio janpio removed the process/candidate Candidate for next Milestone. label Jul 1, 2021
@Jolg42 Jolg42 added the process/candidate Candidate for next Milestone. label Jul 29, 2021
@thebiglabasky
Copy link

Also related to #818
To be looked at together.

@Jolg42
Copy link
Member

Jolg42 commented Aug 20, 2021

Fixed in latest insider version

@Jolg42 Jolg42 closed this as completed Aug 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. kind/bug A reported bug. team/schema Issue for team Schema. topic: autocompletion topic: referentialActions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants