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

Completion for SQL Server Index Clustering #1138

Closed
Tracked by #12376
pimeys opened this issue Apr 25, 2022 · 1 comment · Fixed by #1175
Closed
Tracked by #12376

Completion for SQL Server Index Clustering #1138

pimeys opened this issue Apr 25, 2022 · 1 comment · Fixed by #1175

Comments

@pimeys
Copy link
Contributor

pimeys commented Apr 25, 2022

On SQL Server a user can choose which one of the indices is defining how the data is clustered to the disk. This means an @id, @unique, @@unique, @@id and @@index attributes can now have an argument clustered with two possible values: true or false.

We'd like to auto-complete these:

model A {
  id Int @id(clustered: true)
//           ^ offer clustered
//                      	^ offer true or false
}
model A {
  id   Int
  id2 Int

  @@id([id, id2], clustered: false)
//                ^ offer clustered
//                           ^ offer true or false
}

And so forth for @unique, @@unique and @@index.

Read the full definition from the proposal document.

Rules:

  • Provider must be sqlserver
  • Only one id/unique/index can be clustered per model
  • By default an id is clustered, a unique key or index are nonclustered
@pimeys pimeys added process/candidate Candidate for next Milestone. topic: autocompletion team/schema Issue for team Schema. topic: extendedIndex labels Apr 25, 2022
@Jolg42 Jolg42 added kind/feature A request for a new feature. topic: SQL Server labels Apr 25, 2022
@janpio janpio removed the process/candidate Candidate for next Milestone. label Apr 27, 2022
@Jolg42 Jolg42 changed the title SQL Server Index Clustering Completion for SQL Server Index Clustering May 4, 2022
@Jolg42 Jolg42 self-assigned this May 4, 2022
@janpio janpio added this to the 3.14.0 milestone May 4, 2022
@Jolg42 Jolg42 modified the milestones: 3.14.0, 4.0.x Jun 8, 2022
@Jolg42
Copy link
Member

Jolg42 commented Jun 21, 2022

Note: Implemented without the Only one id/unique/index can be clustered per model rule, validation makes sure it is enforced with Error parsing attribute "@@unique": A model can only hold one clustered index.

Jolg42 added a commit that referenced this issue Jun 21, 2022
* feat(ls): suggest SQL Server index `clustered` and values

Closes #1138

Related https://www.prisma.io/docs/concepts/components/prisma-schema/indexes#configuring-if-indexes-are-clustered-or-non-clustered-with-clustered-sql-server

* Update packages/language-server/src/completion/completionUtils.ts

* cleanup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

3 participants