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(mongodb): completion for composite types #1129
Conversation
🤖 Pull request artifacts
|
Example schema to try, copy and paste then save into a datasource db {
provider = "mongodb"
url = env("DATABASE_URL")
}
type Address {
street String
number Int
alpha Alpha
}
type Alpha {
bravo Bravo
helloA Int
}
type Bravo {
something String
helloBravo Int
}
model User {
id String @id @default(auto()) @map("_id") @db.ObjectId
email String
address Address
// should autocomplete, example of end result:
// @@index([email, address.alpha.bravo.helloBravo])
// try autocompletion by adding a `, address.` below ⬇️ and hitting `Ctrl + space` keys
@@index([email])
} |
{ label: 'id', kind: CompletionItemKind.Field }, | ||
{ label: 'email', kind: CompletionItemKind.Field }, |
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.
OT: Does this really make sense here? I guess that is just how it works right now, but shouldn't it suggest a comma or nothing as there is nothing to auto complete? (Maybe we should add a TODO to the test or open an issue)
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.
Added a comment, I cannot reproduce when using VS Code
// These are returned though the completion will actually be
// No suggestions
// TODO create a test that shows that
}`, | ||
expected: { | ||
isIncomplete: false, | ||
items: [], |
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.
Should this actually suggest alpha
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.
added a TODO comment
Co-authored-by: Jan Piotrowski <piotrowski+github@gmail.com>
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.
Autocompletion works for me with the example schema mentioned in #1129 (comment)!
However, the commands in the "Contributing.md" file didn't work for me (on Ubuntu 20.04) as they were stated. In particular:
-
code --disable-extension Prisma.prisma && code --disable-extension Prisma.prisma-insider
This didn't work for me the first times. I just have a bunch of VSCode extensions opening and the error "Ignoring option disable-extension: not supported for code." appearing in the terminal. Disabling the extensions from the UI, however, worked. -
wget --content-disposition "https://github.com/prisma/language-tools/blob/artifacts/pull-request-artifacts/pr${PR_NUMBER}-prisma.vsix?raw=true"
This correctly downloads the vsix extension locally once I substitutePR_NUMBER=1129
, however, it creates the filepr1129-prisma.vsix?raw=true
rather thanpr1129-prisma.vsix
. I suggest rewriting the command aswget --content-disposition "https://github.com/prisma/language-tools/blob/artifacts/pull-request-artifacts/pr${PR_NUMBER}-prisma.vsix?raw=true" -O pr${PR_NUMBER}-prisma.vsix
Please update the CONTRIBUTING.md file accordingly before merging :)
Thanks @jkomyno, I found the issue about And I already updated the |
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.
Works for me now.
(Take a look at the open comments though please)
id Int @id @map("_id") | ||
email String | ||
address Address | ||
@@index([email, address.alpha.bravo.hello||]) |
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 ||
is a mistage here I guess?
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.
Nice 😄 the code still works, but I'll fix that
Closes #1102
To test read instructions at
https://github.com/prisma/language-tools/blob/joel/composite-types-completion/packages/vscode/CONTRIBUTING.md#pull-requests
Example schema to try, copy and paste then save into a schema.prisma file: