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

Formatter doesn't allow comments on consecutive indices #11455

Closed
lostfictions opened this issue Jan 28, 2022 · 2 comments
Closed

Formatter doesn't allow comments on consecutive indices #11455

lostfictions opened this issue Jan 28, 2022 · 2 comments
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. team/schema Issue for team Schema. tech/engines Issue for tech Engines. topic: prisma format CLI: prisma format
Milestone

Comments

@lostfictions
Copy link

lostfictions commented Jan 28, 2022

Bug description

In a model with multiple indices declared with @@index, the Prisma formatter will move the indices to be on consecutive lines, even if there are comments between them.

How to reproduce

Use this schema:

model Trigram {
  first   String
  second  String
  third   String
  count   Int    @default(0)

  // index for forward access.
  @@index([channel, first, second])
  // index for reverse access.
  @@index([channel, third, second])
}

Run prisma format. The schema will be formatted as follows:

model Trigram {
  first   String
  second  String
  third   String
  count   Int    @default(0)

  // index for forward access.
  // index for reverse access.
  @@index([channel, first, second])
  @@index([channel, third, second])
}

Expected behavior

Comments in between consecutive @@index statements are not reordered.

Prisma information

Environment & setup

  • OS: Linux
  • Database: N/A
  • Node.js version: 17.4.0

Prisma Version

prisma                  : 3.8.1
@prisma/client          : 3.8.1
Current platform        : debian-openssl-1.1.x
Query Engine (Node-API) : libquery-engine 34df67547cf5598f5a6cd3eb45f14ee70c3fb86f (at node_modules/@prisma/engines/libquery_engine-debian-openssl-1.1.x.so.node)
Migration Engine        : migration-engine-cli 34df67547cf5598f5a6cd3eb45f14ee70c3fb86f (at node_modules/@prisma/engines/migration-engine-debian-openssl-1.1.x)
Introspection Engine    : introspection-core 34df67547cf5598f5a6cd3eb45f14ee70c3fb86f (at node_modules/@prisma/engines/introspection-engine-debian-openssl-1.1.x)
Format Binary           : prisma-fmt 34df67547cf5598f5a6cd3eb45f14ee70c3fb86f (at node_modules/@prisma/engines/prisma-fmt-debian-openssl-1.1.x)
Default Engines Hash    : 34df67547cf5598f5a6cd3eb45f14ee70c3fb86f
Studio                  : 0.452.0
@lostfictions lostfictions added the kind/bug A reported bug. label Jan 28, 2022
@janpio janpio added bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. topic: prisma format CLI: prisma format team/schema Issue for team Schema. bug/2-confirmed Bug has been reproduced and confirmed. labels Jan 28, 2022
@janpio
Copy link
Member

janpio commented Jan 28, 2022

Can confirm with this model:

model Trigram {
  id      Int @id
  first   String
  second  String
  third   String
  count   Int    @default(0)

  // index for forward access.
  @@index([count, first, second])
  // index for reverse access.
  @@index([count, third, second])
}

Is reformatted to

model Trigram {
  id     Int    @id
  first  String
  second String
  third  String
  count  Int    @default(0)

  // index for forward access.
  // index for reverse access.
  @@index([count, first, second])
  @@index([count, third, second])
}

@floelhoeffel floelhoeffel removed the bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. label Feb 10, 2022
@janpio janpio added the tech/engines Issue for tech Engines. label Mar 24, 2022
@tomhoule
Copy link
Contributor

tomhoule commented Jul 7, 2022

The schema above now reformats to:

model Trigram {
  first  String
  second String
  third  String
  count  Int    @default(0)

  // index for forward access.
  @@index([channel, first, second])
  // index for reverse access.
  @@index([channel, third, second])
}

that was fixed in prisma/prisma-engines#3030. So I think we can close this issue, thanks for reporting the problem!

@tomhoule tomhoule closed this as completed Jul 7, 2022
@janpio janpio added this to the 4.1.0 milestone Jul 7, 2022
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 Issue for tech Engines. topic: prisma format CLI: prisma format
Projects
None yet
Development

No branches or pull requests

4 participants