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

feat(mongodb): completion for composite types #1129

Merged
merged 14 commits into from May 6, 2022

Conversation

Jolg42
Copy link
Member

@Jolg42 Jolg42 commented Apr 22, 2022

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:

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])
}

@Jolg42 Jolg42 added this to the 3.13.0 milestone Apr 22, 2022
@Jolg42 Jolg42 modified the milestones: 3.13.0, 3.14.0 Apr 28, 2022
@github-actions
Copy link

github-actions bot commented Apr 28, 2022

🤖 Pull request artifacts

file commit
pr1129-prisma.vsix 3f00f71

github-actions bot added a commit that referenced this pull request Apr 28, 2022
github-actions bot added a commit that referenced this pull request May 3, 2022
github-actions bot added a commit that referenced this pull request May 3, 2022
@Jolg42 Jolg42 marked this pull request as ready for review May 3, 2022 16:06
@Jolg42 Jolg42 requested a review from jkomyno May 3, 2022 16:08
@Jolg42
Copy link
Member Author

Jolg42 commented May 3, 2022

Example schema to try, copy and paste then save into a schema.prisma file:

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])
}

github-actions bot added a commit that referenced this pull request May 4, 2022
github-actions bot added a commit that referenced this pull request May 4, 2022
Comment on lines +1339 to +1340
{ label: 'id', kind: CompletionItemKind.Field },
{ label: 'email', kind: CompletionItemKind.Field },
Copy link
Member

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)

Copy link
Member Author

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: [],
Copy link
Member

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?

Copy link
Member Author

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>
github-actions bot added a commit that referenced this pull request May 4, 2022
github-actions bot added a commit that referenced this pull request May 5, 2022
Copy link
Contributor

@jkomyno jkomyno left a 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 substitute PR_NUMBER=1129, however, it creates the file pr1129-prisma.vsix?raw=true rather than pr1129-prisma.vsix. I suggest rewriting the command as wget --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 :)

@Jolg42
Copy link
Member Author

Jolg42 commented May 5, 2022

Thanks @jkomyno, I found the issue about --disable-extension and will update the README

And I already updated the wget with --content-disposition, though it was indeed missing initially

Copy link
Member

@janpio janpio left a 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)

github-actions bot added a commit that referenced this pull request May 5, 2022
github-actions bot added a commit that referenced this pull request May 5, 2022
github-actions bot added a commit that referenced this pull request May 6, 2022
@Jolg42 Jolg42 merged commit 3458521 into main May 6, 2022
@Jolg42 Jolg42 deleted the joel/composite-types-completion branch May 6, 2022 09:06
id Int @id @map("_id")
email String
address Address
@@index([email, address.alpha.bravo.hello||])
Copy link
Member

@janpio janpio May 6, 2022

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?

Copy link
Member Author

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

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.

Autocompletion support for composite type indexes
4 participants