Skip to content

Query Postgres Table with UUID as ID raises error #479

@yim77

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions