SQL Server: crash using native type @db.UniqueIdentifier: `Conversion failed when converting from a character string to uniqueidentifier.`
See original GitHub issueBug description
Even with a very minimal schema.prisma, calling findUnique()
on a PrismaClient() causes Node to run out of memory and crash.
How to reproduce
- I was able to introspect my MS Azure SQL Edge (essentially SQL Server) database, so my database URL is configured correctly.
npx prisma generate
- Add the following to test_prisma.ts:
import { PrismaClient } from "@prisma/client";
const prisma = new PrismaClient();
prisma.background_job_requests
.findUnique({ where: { id: "123" } })
.then((d: any) => console.log(`found one :${d}`))
.catch((e: any) => console.error(e));
npx ts-node ./test_prisma.ts
Expected behavior
Script runs and exits without error.
Prisma information
model background_job_requests {
id String @id(map: "PK__backgrou__3213E83F6BC835AF") @default(dbgenerated("newid()"), map: "DF__background_j__id__0BBD6DF4") @db.UniqueIdentifier
created_at DateTime @db.DateTimeOffset
job_name String @db.VarChar(100)
args_json String? @db.VarChar(Max)
}
Environment & setup
- OS: macOS
- Database: MS Azure SQL Edge (essentially the same as MS SQL Server)
- Node.js version: v14.15.4
Prisma Version
prisma : 3.9.0
@prisma/client : 3.10.0
Current platform : darwin-arm64
Query Engine (Node-API) : libquery-engine bcc2ff906db47790ee902e7bbc76d7ffb1893009 (at node_modules/@prisma/engines/libquery_engine-darwin-arm64.dylib.node)
Migration Engine : migration-engine-cli bcc2ff906db47790ee902e7bbc76d7ffb1893009 (at node_modules/@prisma/engines/migration-engine-darwin-arm64)
Introspection Engine : introspection-core bcc2ff906db47790ee902e7bbc76d7ffb1893009 (at node_modules/@prisma/engines/introspection-engine-darwin-arm64)
Format Binary : prisma-fmt bcc2ff906db47790ee902e7bbc76d7ffb1893009 (at node_modules/@prisma/engines/prisma-fmt-darwin-arm64)
Default Engines Hash : bcc2ff906db47790ee902e7bbc76d7ffb1893009
Studio : 0.457.0
Issue Analytics
- State:
- Created 2 years ago
- Comments:12 (9 by maintainers)
Top Results From Across the Web
Conversion failed when converting from a character string to ...
It looked like SQL Server attempted to parse the text as a uniqueidentifier because it recognized that some of the text was a...
Read more >SQL Conversion failed when converting from a character ...
SQL Conversion failed when converting from a character string to uniqueidentifier. DataSource Controls - SqlDataSource, ObjectDataSource, etc.
Read more >Conversion failed when converting from a character string to ...
The text string '@siteId' can't be converted into a uniqueidentifier for that join, and will result in the error you mentioned:
Read more >Conversion failed when converting from a ... - SQLServerCentral
2. Don't rely on implict conversions. CAST the GUID string to a UNIQUEIDENTIFIER and compare it to your column. Don't CAST the column...
Read more >[Microsoft SQL Server]Conversion failed when converting from ...
When you query the unique identifier column through an MS SQL server native client or third-party software that uses OLEDB in order to...
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 FreeTop 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
Top GitHub Comments
Thanks for responding! I just tried again with consistent version 3.14.0 and a new, almost empty database. The database schema is simply:
I then ran
npx prisma db pull
, which produced the following in myschema.prisma
:My test script:
When I run the test script with
ts-node
, I get the OOM crash:However, if I compile the TS into JS by running
tsc
, then running the compiled script produced more reasonable output:So I don’t know if this is a
ts-node
related problem, or a prisma problem, or maybe it’s my version of Node, which needs to be upgraded.I was indeed using
"123"
as the value. I think that prisma should raise an error given an invalid value, not run out of memory and crash.That said, I’m not currently using prisma, and I’m not personally invested in this issue getting fixed, so if y’all want to close it I’m fine with that.