I am looking at the docs (<https://www.prisma.io/d...
# orm-help
m
I am looking at the docs (https://www.prisma.io/docs/data-model-and-migrations/introspection-mapping-to-existing-db-soi1/), because I am having an issue with a specific join type. Similar to what is in the docs here
Copy code
type Bill @pgTable(name: "bill") {
  bill: String!
  id: Int! @unique
  bill_products: [Bill_product]
}

type Bill_product @pgTable(name: "bill_product") {
  bill: Bill @pgRelation(column: "bill_id")
  product: Product @pgRelation(column: "product_id")
  some_other_column: String!
}

type Product @pgTable(name: "product") {
  id: Int! @unique
  product: String!
  bill_products: [Bill_product]
}
I am trying to access
some_other_column
data when I query
Copy code
query {
  bill(where: { id: 1 }){
    id
    bill_products {
      product {
        id
        product
      }
      some_other_column
    }
  }
}
When I run the SQL from the docs, add the types to my
app.prisma
file then run
prisma deploy
I get 3 errors
Bill_product ✖ The required field 'id' is missing and has to have the format: id: ID! @unique or id: UUID! @unique or id: Int! @unique.
Copy code
Bill ✖ The relation field ‘bill_products’ has the wrong format: ‘[Bill_product]’ Possible Formats
: ‘Bill_Product’, ‘Bill_product!‘, ‘[Bill_product!]\!’
Copy code
Products ✖ The relation field ‘bill_products’ has the wrong format: ‘[Bill_product]’ Possible Formats
: ‘Bill_Product’, ‘Bill_product!‘, ‘[Bill_product!]\!’
When I resolve these 3 errors and run
prisma deploy
all is well When I try to query
Copy code
query {
  bill(where: { id: 1 }){
    id
    bill_products {
      product {
        id
        product
      }
      some_other_column
    }
  }
}
I get errors in PostgreSQL
Copy code
ERROR:  column Alias.id does not exist at character 217
STATEMENT:  select 
  "Alias"."id", 
  "RelationTable"."id" as "__RelatedModel__", 
  "RelationTable"."bill_id" as "__ParentModel__"
from "public"."bill_product" as "Alias"
  join "public"."bill_product" as "RelationTable"
  on "Alias"."id" = "RelationTable"."id"
where "RelationTable"."bill_id" in ($1)
order by "RelationTable"."id" asc