Skip to content

Query Postgres Table with UUID as ID raises error #479

Closed

Description

@yim77

If I try to query a row from a postgres table with a id of type UUID prisma raises an error.

Postgres version: PostgreSQL 11.1 (Debian 11.1-1.pgdg90+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 6.3.0-18+deb9u1) 6.3.0 20170516, 64-bit

Prisma2 version: 2.0.0-alpha.159

DB Script:

CREATE TABLE public."User"
(
    age integer,
    name text COLLATE pg_catalog."default" NOT NULL DEFAULT ''::text,
    id uuid NOT NULL DEFAULT uuid_generate_v1(),
    CONSTRAINT id PRIMARY KEY (id)
)
WITH (
    OIDS = FALSE
)
TABLESPACE pg_default;

ALTER TABLE public."User"
    OWNER to postgres;

Schema:

model User {
id   String @default(uuid()) @id
age  Int?
name String
post Post[]
}

Code:

const MyFunc = async function() {
  const MyUser = await photon.users.findOne({where: {id: "936958ea-cb04-11e9-bcba-0242ac110002"},});
  console.log(MyUser);
}

MyFunc()

Error: Reason: Error in connector: Error querying the database: error serializing parameter 0: cannot convert to or from a Postgres value of type uuid

Queries on same table with findMany() is working perfect.

Activity

  1. pantharshit00 commented on Sep 2, 2019

    @pantharshit00
    Contributor

    I can confirm this.

    Also, the thing to note that when I use lift to bootstrap this, it created the column as text for uuid.

  2. added
    bug/2-confirmed
    kind/bug
    on Sep 2, 2019
  3. pantharshit00 commented on Sep 2, 2019

    @pantharshit00
    Contributor

    Created an issue in the lift repository for the related issue: prisma/migrate#114

  4. benjamincanac commented on Oct 3, 2019

    @benjamincanac

    Any update on this? I encounter the same problem.

    Thanks!

  5. divyenduz commented on Oct 11, 2019

    @divyenduz

    Internal note: link this to custom type EPIC issue, dropping from this sprint

  6. added
    topic: client types
    on Feb 24, 2020
  7. added a commit that references this issue on Apr 14, 2020
    e1717b1
  8. pantharshit00 commented on Jan 3, 2021

    @pantharshit00
    Contributor

    I believe fix for this was released a long time ago, please comment if someone is still experiencing this.

  9. pantharshit00 commented on Jan 3, 2021

    @pantharshit00
    Contributor

    image

    Confirmed as well :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug/2-confirmedkind/bugtopic: client typestopic: native database types

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions