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.

Table and column name mapping bug

See original GitHub issue

Hi, I’ve encountered a weird bug with how I’m using mappings and prisma-erd-generator. Everything in Prisma generates the way I’d expect but prisma-erd-generator generates a svg for me with names I’m not expecting. Here’s some example that recreates the issue: prisma.schema:

generator client {
  provider      = "prisma-client-js"
  output        = "client"
}

generator erd {
  provider = "prisma-erd-generator"
  output = "./erd.svg"
  theme = "default"
}

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

model Store {
  @@map("stores")

  id                String            @map("store_id") @id @default(uuid())

  employees         Employee[]
  customers         Customer[]
}

model Employee {
  @@map("employees")

  id                String            @map("employee_id") @id @default(uuid())
  storeId           String            @map("store_id")

  store             Store             @relation(fields: [storeId], references: [id])
  orders            Order[]
}

model Customer {
  @@map("customers")

  id                String            @map("customer_id") @id @default(uuid())
  storeId           String            @map("store_id")

  store             Store             @relation(fields: [storeId], references: [id])
  orders            Order[]
}

model Order {
  @@map("orders")

  id                String            @map("order_id") @id @default(uuid()) 
  employeeId        String            @map("employee_id")
  customerId        String            @map("customer_id")

  employee          Employee          @relation(fields: [employeeId], references: [id])
  customer          Customer          @relation(fields: [customerId], references: [id])
}

SVG generated by prisma-erd-generator: erd

What I expecting to see in the SVG was: the PK for the orders table should be order_id, PK for the employees table should be employee_id, and PK for customers should be customer_id.

Am I doing something wrong?

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
francismanansalacommented, Jul 26, 2022

@francismanansala can you give v1.0.2 a test. I’m trying on my project now but I didn’t have this issue before. Test case was written so I’m assuming this is safe to be closed

Works perfectly within my test scenario and project 🚀 Thanks for the quick turn around on this @keonik!

1reaction
keonikcommented, Jul 26, 2022

@francismanansala can you give v1.0.2 a test. I’m trying on my project now but I didn’t have this issue before. Test case was written so I’m assuming this is safe to be closed

Read more comments on GitHub >

github_iconTop Results From Across the Web

Oracle Table and Column name Bug
Oracle seems to be unable to remember whether a table or column name I enter is Lower case, upper case or camel case....
Read more >
[DOC] Glue table column name mapping with connector ...
Run a select query on the table and observe that no information is returned. Add columnMapping in the Glue table's Table properties <Glue...
Read more >
Mapping: Table contains physical column name referred to ...
When you use a named column reference in any way on one class field, make sure ALL references use the exact same name....
Read more >
Delta tables: Cannot set default column mapping mode ...
I have managed to do it in SQL using TBLPROPERTIES with the CREATE TABLE statement like so: CREATE TABLE table_bronze_csv; USING CSV; OPTIONS...
Read more >
306356 – [DB] Handle table/column names using ... - Bugs
Bug 306356 - [DB] Handle table/column names using reserved words without modifying ... readValuesFromStatement(AbstractHorizontalClassMapping.java:295) at ...
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