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

Option for disabling auto relation insertion #720

Closed
euberdeveloper opened this issue Feb 21, 2021 · 2 comments
Closed

Option for disabling auto relation insertion #720

euberdeveloper opened this issue Feb 21, 2021 · 2 comments
Labels
kind/feature A request for a new feature. kind/feedback Issue for gathering feedback.

Comments

@euberdeveloper
Copy link

Problem

I am always frustrated when I have something like this:

model Persona {
    uid              String          @id @default(uuid())
    codice_fiscale   String?
    nome             String
    cognome          String
    sesso            Sesso
    data_nascita     DateTime
    luogo_di_nascita LuogoDiNascita?
    residenza        Residenza?
    domicili         Domicilio[]
    creata_il        DateTime

    @@map("persona")
}

// ....

model Presidente {
    uid                 String   @id
    data_inizio_mandato DateTime
    data_fine_mandato   DateTime
    firma               String
    persona             Persona  @relation(fields: [uid], references: [uid])

    @@map("presidente")
}

Where you can see that President ISA Person, hence by ER logic a president should always be able to reach the fields of the person he refers, but person should not be able to see its president.

When with VSCODE i format the code (Ctrl+Shift+i on Ubuntu), I obtain this:

model Persona {
    uid              String          @id @default(uuid())
    codice_fiscale   String?
    nome             String
    cognome          String
    sesso            Sesso
    data_nascita     DateTime
    luogo_di_nascita LuogoDiNascita?
    residenza        Residenza?
    domicili         Domicilio[]
    creata_il        DateTime

    @@map("persona")
    Presidente Presidente[] // This should not be added
}

Firstly, it is not true that a Person can be more than a President, secondly I do not want at all that the field president is added to Person.

Suggested solution

The easiest solution would be able to disable from options this feature, so that when I indent the code, the code is only linted but not "improved" by adding the second part of a relation.

Alternatives

An alternative could be able to configure from settings how and when the second part of a relation would be added.

@euberdeveloper
Copy link
Author

Update: After having some experience, I suggest adding the field to all the sides of the relation, there was really no reason not to do it. I still would prefer a warning instead of them added automatically.

@carmenberndt
Copy link
Contributor

related #91

@carmenberndt carmenberndt added kind/feedback Issue for gathering feedback. kind/feature A request for a new feature. labels Mar 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature A request for a new feature. kind/feedback Issue for gathering feedback.
Projects
None yet
Development

No branches or pull requests

3 participants