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

Embedded document _id of type ObjectId are introspected without native type @db.ObjectId #11396

Closed
janpio opened this issue Jan 25, 2022 · 0 comments · Fixed by prisma/prisma-engines#2647
Assignees
Labels
bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. kind/bug A reported bug. team/schema Issue for team Schema. topic: embedded documents topic: introspection topic: mongodb
Milestone

Comments

@janpio
Copy link
Member

janpio commented Jan 25, 2022

Prisma 1 MongoDB supported embedded documents. A document could for example look like this:

{
  "_id": {
    "$oid": "61ef1a40be07770008a7b87b"
  },
  "title": "title",
  "ids": [
    {
      "name": "name",
      "value": "value",
      "_id": {
        "$oid": "61ef1a8dbe07770008a7b87d"
      }
    }
  ]
}

create via this Prisma 1 schema:

type Foo {
  id: ID! @id
  title: String!
  ids: [IdSet!]!
}

This is currently introspected into this Prisma schema:

model Foo {
  id     String    @id @default(dbgenerated()) @map("_id") @db.ObjectId
  ids    FooIds[]
  title  String
}

type FooIds {
  id    String @map("_id")
  name  String
  value String
}

Note how FooIds.id is only of scalar type String although the data clearly shows it being $oid, which we could probably render as @db.ObjectId.

(We are not sure where the value comes from yet, so if this deserves the @default(dbgenerated()) as well, but suspect Prisma 1 did generate that manually and then inserted the value - as _id usually does not really exist for embedded types afaik.)

@janpio janpio added bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. kind/bug A reported bug. topic: introspection team/schema Issue for team Schema. topic: embedded documents labels Jan 25, 2022
@janpio janpio changed the title Embedded document _id of type ObjectId are introspected without native Type Embedded document _id of type ObjectId are introspected without native type @db.ObjectId Jan 25, 2022
@floelhoeffel floelhoeffel added this to the 3.10.0 milestone Feb 2, 2022
@do4gr do4gr self-assigned this Feb 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. kind/bug A reported bug. team/schema Issue for team Schema. topic: embedded documents topic: introspection topic: mongodb
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants