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.

Feedback wanted: Introspection

See original GitHub issue

Hey everyone,

in the last few releases we improved our Introspection feature prisma introspect, most notably with “More robust introspection by keeping manual changes in the Prisma schema file” in 2.6.0 but also many smaller bug fixes. We think it is pretty stable now, and would love to hear from you, our users, how you have been using prisma introspect recently!

  • Did prisma introspect work for your database?
  • What is working well for you?
  • What problems did you encounter? What functionality is still missing?

It would be awesome if you could leave your comments either on the messages linking to this issue on Twitter or Slack, or just as a comment below! ✍️

💚 By the way, we loooove to hear about positive experiences ✨ as well - which sometimes gets lost in GitHub issues where it is about bug and problems most of the time - so if you had a great experience and things just worked, please leave a comment below as well 💖

Thanks!


We are aware already of 2 big areas where improvements would help some users:

  • Not all native database types and their attributes are supported yet by Introspection and Prisma in general, and we are going to on this via what we call "Native Database Types ".
  • And some people wish for configuration option of the Introspection result and Schema. We are collecting these suggestions under the term and label “Introspection Configuration”.

Follow these issues for updates on these topics or leave your comments there as well.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:27 (10 by maintainers)

github_iconTop GitHub Comments

10reactions
tajnymagcommented, Oct 12, 2020

Generally I do like the introspection. However, there are still some corner cases I hate personally. I’ve yet found two things I miss the most.

  1. Firstly the naming transformation. I would expect to have the ability to let prisma convert snake_case to camelCase automatically and change plural to singular table names. Though I understand this is not something deal breaking and one can use prisma-schema-transformer.

  2. What I’ve found to be deal breaking for me, is the the way relation naming is handled. It seems prisma uses the referenced table name as the field name. What I would expect, would be to use the relation name from sql field {{relationName}}_id.

CREATE TABLE contracts (
    id integer PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY,
    name text NOT NULL,
    description text,
    price_id integer REFERENCES monetary_values(id) NOT NULL,
    responsible_user_id integer REFERENCES users(id) NOT NULL,
    client_id integer REFERENCES clients(id) NOT NULL
);

gets transfomed into:

model contracts {
  id                  Int                 @id @default(autoincrement())
  name                String
  description         String?
  price_id            Int
  responsible_user_id Int
  client_id           Int
  clients             clients             @relation(fields: [client_id], references: [id])
  monetary_values     monetary_values     @relation(fields: [price_id], references: [id])
  users               users               @relation(fields: [responsible_user_id], references: [id])
}

without naming transformation I would expect the result to be:

model contracts {
  id                  Int                 @id @default(autoincrement())
  name                String
  description         String?
  price_id            Int
  responsible_user_id Int
  client_id           Int
  client              clients             @relation(fields: [client_id], references: [id])
  price               monetary_values     @relation(fields: [price_id], references: [id])
  responsible_user    users               @relation(fields: [responsible_user_id], references: [id])
}

I do understand that everyone names their fields differently. In that case, could we perhaps specify a relation name template string? Or give prisma a transformer function to rename the fields ourselves? A wiki page with recommended foreign key naming scheme would suffice too.

3reactions
richmonkeyscommented, Dec 2, 2020

particular relation fields with custom names are getting renamed when they shouldn’t be Screen Recording 2020-11-26 at 06 34 11 PM

just in this one model though, notice owner in the model above time_entries is left untouched, even though it’s also a relation to people

I was having the similar issue where some of the models are ok but some models’ relation field names get overwritten by introspect.

I solved it by setting a name for all the relation fields. e.g.

model people {
  ...
  time_entries time_entries @relation("people_time_entries")
}

model projects {
  ...
  time_entries time_entries @relation("projects_time_entries")
}

model time_entries {
  ...
  project    projects @relation("projects_time_entries", fields: [project_id], references: [id])
  person     people   @relation("people_time_entries", fields: [user_id], references: [id])
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

4 Steps To Hone Your Powers Of Introspection
This guide is for people who want to practice self awareness and introspection, but don't have a lot of time. Over this 7-minute...
Read more >
In Search of Our True Selves: Feedback as a Path to Self ...
Here we define feedback as new, true information about oneself that could not have been accessed through introspection alone.
Read more >
Introspection: Definition, Uses, Examples, and Tips
Introspection is a psychological process that involves looking inward to examine one's own thoughts, emotions, judgments, and perceptions.
Read more >
87 Self-Reflection Questions for Introspection [+Exercises]
What do I want most in life? What is life asking of me? Which is worse: failing or never trying? If I try...
Read more >
Introspection: Definition (in Psychology), Examples, and ...
Introspection Examples · Who am I? I got two clear answers. · My self-reflection · Who do I want to be? · What...
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