question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Format adds `@unique` without space

See original GitHub issue

This schema is formatted to have @unique but without a space between it and the previous attribute:

generator client {
  provider        = "prisma-client-js"
  previewFeatures = "mongodb"
}

datasource db {
  provider = "mongodb"
  url      = "m...ty"
}

model Foo {
  id       String   @id @default(auto()) @map("_id") @db.ObjectId
  name     String   @unique
  json     Json
  bar      Bar
  bars     Bar[]
  baz      Baz      @relation(fields: [bazId], references: [id])
  bazId    String   @db.ObjectId
  list     String[]
  jsonList Json[]
}

type Bar {
  label  String
  number Int
}

model Baz {
  id  String @id @default(auto()) @map("_id") @db.ObjectId
  foo Foo?
}

leads to

  bazId    String   @db.ObjectId@unique
                               ^^

Formatting again then fixes to

bazId    String   @unique @db.ObjectId

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
tomhoulecommented, Apr 7, 2022

Found the root cause, it will be easy to add spacing between attributes, but ordering them correctly (so reformat is idempotent) will take more work. Let’s try to tackle first things first.

0reactions
tomhoulecommented, Apr 7, 2022

Ok my reproduction attemps were flawed (reason mentioned in previous message), I can confirm that at 7e91d3111425c8915dcdd8e37bca69ddcb2c883d. Formatting once produces the schema with the weirdly placed @unique, second reformatting produces the good schema from my second message.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Extract a unique distinct list and ignore blanks - Get Digital Help
This article demonstrates formulas that extract unique distinct values and ignore blank empty cells. Table of contents Extract a unique ...
Read more >
Unique values ignore blanks - Excel formula - Exceljet
To extract a list of unique values from a set of data, ignoring blank cells, you can use the UNIQUE function together with...
Read more >
Spreadsheets get unique names but ignore blank cells
So far I've got this formula that returns all of the unique names from column A but I don't know how to go...
Read more >
Fix text-formatted numbers by applying a number format
The TRIM function removes spaces from text except for single spaces between words. The CLEAN function removes all nonprintable characters from text.
Read more >
SELECT DISTINCT in extra space data from a single column ...
Add a column with the name like [NormalizedCityName] , then copy your values into it and: replace multiple spaces with one space; add...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found