Query Postgres Table with UUID as ID raises error
See original GitHub issueIf 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.
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (5 by maintainers)
Top Results From Across the Web
Postgres UUID type error - Stack Overflow
You might need to add explicit type casts. I tried with adding the schema like: id uuid PRIMARY KEY DEFAULT public.uuid_generate_v4() (as seen ......
Read more >Auto-generated primary keys: UUID, serial or identity column?
This article explores the old question what to use for autogenerated primary keys: UUID, serial or identity column?
Read more >What happens when an automatically generated UUID ...
Upon each insert where an UUID is not specified, a new UUID (v4) is automatically generated to be set as the primary key....
Read more >A Complete Guide to UUIDs in PostgreSQL - Arctype
The foundation for a table in a relational database is the primary key. Because of its importance, we have to give special consideration...
Read more >GraphQL and UUID type on Postgres - Hasura
Enumeration of entries: Another problem is that it's very easy to enumerate all the entries of your table with a primary key. A...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Any update on this? I encounter the same problem.
Thanks!
Confirmed as well 😃