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

Cannot add comments to my @@unique constraints #1186

Closed
paulintrognon opened this issue Jun 27, 2022 · 2 comments · Fixed by prisma/prisma-engines#3030
Closed

Cannot add comments to my @@unique constraints #1186

paulintrognon opened this issue Jun 27, 2022 · 2 comments · Fixed by prisma/prisma-engines#3030
Assignees
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. team/schema Issue for team Schema. tech/engines/datamodel Issue about parsing/validation/rendering of the Prisma schema topic: comments topic: formatting
Milestone

Comments

@paulintrognon
Copy link

paulintrognon commented Jun 27, 2022

Bug description

I cannot add comments to the @@unique([field1, field2]) constraints of my models: they are deleted or moved away.

How to reproduce

  1. Create the schema.prisma file:
model MyModel {
  // Example Comment
  field1 Int // Comment Field 1
  field2 Int // Comment Field 2
  field3 Int // Comment Field 3

  // I will survive but will be on my own
  @@unique([field1, field2]) // I WILL BE DELETED

  // I will survive as well
  @@unique([field1, field3]) // GOODBYE WORLD
}
  1. Save
  2. Result:
model MyModel {
  // Example Comment
  field1 Int // Comment Field 1
  field2 Int // Comment Field 2
  field3 Int // Comment Field 3

  // I will survive but will be on my own

  // I will survive as well
  @@unique([field1, field2])
  @@unique([field1, field3])
}

Expected behavior

We should be able to comment our constraints to give extra contextual or historical information of why we made those constraints, at the moment I have to put all that information in the only allowed comment at the top of the contraints

Environment & setup

  • OS: Debian
  • Editor: VSCode
  • Editor version: 1.61.8
  • Extension version: 3.15.0
@janpio janpio added bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. kind/bug A reported bug. topic: formatting topic: comments team/schema Issue for team Schema. bug/2-confirmed Bug has been reproduced and confirmed. and removed bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. labels Jun 27, 2022
@janpio
Copy link
Member

janpio commented Jun 27, 2022

I can confirm that the double slash comments in the same line are removed, and also that the double slash comment before the line do not stay together with the @@unique (as they potentially are supposed to).

@tomhoule tomhoule added tech/engines/datamodel Issue about parsing/validation/rendering of the Prisma schema process/candidate Candidate for next Milestone. labels Jun 28, 2022
@floelhoeffel floelhoeffel removed the process/candidate Candidate for next Milestone. label Jun 29, 2022
@tomhoule tomhoule self-assigned this Jul 2, 2022
tomhoule added a commit to prisma/prisma-engines that referenced this issue Jul 4, 2022
This is achieved by a massive cleanup and simplification of the
AST reformatter.

- The comments attached to block attributes will follow them after
  reformatting.
- Enum attributes do not get reformatted with an extra leading space
  anymore
- Empty lines at beginning and end of blocks are reformatted away.

closes prisma/language-tools#1186

Also included:

- diagnostics: delete dead warnings code and stop using thiserror —
  compile times will thank us.
tomhoule added a commit to prisma/prisma-engines that referenced this issue Jul 4, 2022
This is achieved by a massive cleanup and simplification of the
AST reformatter.

- The comments attached to block attributes will follow them after
  reformatting.
- Enum attributes do not get reformatted with an extra leading space
  anymore
- Empty lines at beginning and end of blocks are reformatted away.

closes prisma/language-tools#1186

Also included:

- diagnostics: delete dead warnings code and stop using thiserror —
  compile times will thank us.
tomhoule added a commit to prisma/prisma-engines that referenced this issue Jul 4, 2022
This is achieved by a massive cleanup and simplification of the
AST reformatter.

- The comments attached to block attributes will follow them after
  reformatting.
- Enum attributes do not get reformatted with an extra leading space
  anymore
- Empty lines at beginning and end of blocks are reformatted away.

closes prisma/language-tools#1186

Also included:

- diagnostics: delete dead warnings code and stop using thiserror —
  compile times will thank us.
tomhoule added a commit to prisma/prisma-engines that referenced this issue Jul 4, 2022
This is achieved by a massive cleanup and simplification of the
AST reformatter.

- The comments attached to block attributes will follow them after
  reformatting.
- Enum attributes do not get reformatted with an extra leading space
  anymore
- Empty lines at beginning and end of blocks are reformatted away.

closes prisma/language-tools#1186

Also included:

- diagnostics: delete dead warnings code and stop using thiserror —
  compile times will thank us.
tomhoule added a commit to prisma/prisma-engines that referenced this issue Jul 4, 2022
This is achieved by a massive cleanup and simplification of the
AST reformatter.

- The comments attached to block attributes will follow them after
  reformatting.
- Enum attributes do not get reformatted with an extra leading space
  anymore
- Empty lines at beginning and end of blocks are reformatted away.

closes prisma/language-tools#1186

Also included:

- diagnostics: delete dead warnings code and stop using thiserror —
  compile times will thank us.
tomhoule added a commit to prisma/prisma-engines that referenced this issue Jul 5, 2022
This is achieved by a massive cleanup and simplification of the
AST reformatter.

- The comments attached to block attributes will follow them after
  reformatting.
- Enum attributes do not get reformatted with an extra leading space
  anymore
- Empty lines at beginning and end of blocks are reformatted away.

closes prisma/language-tools#1186

Also included:

- diagnostics: delete dead warnings code and stop using thiserror —
  compile times will thank us.
tomhoule added a commit to prisma/prisma-engines that referenced this issue Jul 5, 2022
This is achieved by a massive cleanup and simplification of the
AST reformatter.

- The comments attached to block attributes will follow them after
  reformatting.
- Enum attributes do not get reformatted with an extra leading space
  anymore
- Empty lines at beginning and end of blocks are reformatted away.

closes prisma/language-tools#1186

Also included:

- diagnostics: delete dead warnings code and stop using thiserror —
  compile times will thank us.
tomhoule added a commit to prisma/prisma-engines that referenced this issue Jul 5, 2022
This is achieved by a massive cleanup and simplification of the
AST reformatter.

- The comments attached to block attributes will follow them after
  reformatting.
- Enum attributes do not get reformatted with an extra leading space
  anymore
- Empty lines at beginning and end of blocks are reformatted away.

closes prisma/language-tools#1186

Also included:

- diagnostics: delete dead warnings code and stop using thiserror —
  compile times will thank us.
@Jolg42 Jolg42 added this to the 4.1.0 milestone Jul 5, 2022
@paulintrognon
Copy link
Author

Awesome!! Thanks a lot ❤️

yume-chan pushed a commit to yume-chan/prisma-engines that referenced this issue Jul 8, 2022
This is achieved by a massive cleanup and simplification of the
AST reformatter.

- The comments attached to block attributes will follow them after
  reformatting.
- Enum attributes do not get reformatted with an extra leading space
  anymore
- Empty lines at beginning and end of blocks are reformatted away.

closes prisma/language-tools#1186

Also included:

- diagnostics: delete dead warnings code and stop using thiserror —
  compile times will thank us.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. team/schema Issue for team Schema. tech/engines/datamodel Issue about parsing/validation/rendering of the Prisma schema topic: comments topic: formatting
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants