question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Conversion failed when converting from a character string to uniqueidentifier.

See original GitHub issue

Hi Prisma Team! My Prisma Client just crashed. This is the report:

Versions

Name Version
Node v14.15.1
OS windows
Prisma Client 2.17.0
Query Engine undefined
Database undefined

Query

query {
  findManytable(where: {
    Id: "X"
  }) {
    Id
    Value
  }
}

Logs

nvironment variables not found at undefined  
  prisma:tryLoadEnv No Environment variables loaded  
  prisma:client { clientVersion: '2.17.0' }  
  prisma:engine { cwd: 'C:\\temp\\prisma-issue' }  
  prisma:engine Search for Query Engine in C:\temp\prisma-issue\node_modules\.prisma\client  
  prisma:engine Search for Query Engine in C:\temp\prisma-issue\node_modules\.prisma\client  
  prisma:engine {
  prisma:engine   flags: [
  prisma:engine     '--enable-experimental=microsoftSqlServer',
  prisma:engine     '--enable-raw-queries',
  prisma:engine     '--port',
  prisma:engine     '54855'
  prisma:engine   ]
  prisma:engine }  
  prisma:engine stdout  Starting a mssql pool with 33 connections.  
  prisma:engine stdout  TLS encryption is not enabled. All traffic including the login credentials are not encrypted.  
  prisma:engine stdout  Database change from 'd2i_demoscorecard_3' to 'master'  
  prisma:engine stdout  Changed database context to 'd2i_demoscorecard_3'.  
  prisma:engine stdout  SQL collation change from None to None  
  prisma:engine stdout  Microsoft SQL Server�� version 537395215  
  prisma:engine stdout  Packet size change from '4096' to '4096'  
  prisma:engine stdout  Started http server on http://127.0.0.1:54855  
  prisma:engine Search for Query Engine in C:\temp\prisma-issue\node_modules\.prisma\client  
  prisma:engine stdout  Conversion failed when converting from a character string to uniqueidentifier.  
  prisma:engine {
  prisma:engine   error: PrismaClientUnknownRequestError2 [PrismaClientUnknownRequestError]: Error occurred during query execution:
  prisma:engine   ConnectorError(ConnectorError { user_facing_error: None, kind: QueryError(TokenError { code: 8169, state: 2, class: 16, message: "Conversion failed when converting from a character string to uniqueidentifier.", server: "MINIBEAST", procedure: "", line: 1 }) })
  prisma:engine       at NodeEngine.graphQLToJSError (C:\temp\prisma-issue\node_modules\@prisma\client\runtime\index.js:27156:14)
  prisma:engine       at NodeEngine.request (C:\temp\prisma-issue\node_modules\@prisma\client\runtime\index.js:27052:24)
  prisma:engine       at processTicksAndRejections (internal/process/task_queues.js:93:5)
  prisma:engine       at async cb (C:\temp\prisma-issue\node_modules\@prisma\client\runtime\index.js:78659:26)
  prisma:engine       at async main (C:\temp\prisma-issue\index.js:5:16) {
  prisma:engine     clientVersion: '2.17.0'
  prisma:engine   }
  prisma:engine }  
  prisma:engine stdout  Conversion failed when converting from a character string to uniqueidentifier.  
  prisma:engine {
  prisma:engine   error: PrismaClientUnknownRequestError2 [PrismaClientUnknownRequestError]: Error occurred during query execution:
  prisma:engine   ConnectorError(ConnectorError { user_facing_error: None, kind: QueryError(TokenError { code: 8169, state: 2, class: 16, message: "Conversion failed when converting from a character string to uniqueidentifier.", server: "MINIBEAST", procedure: "", line: 1 }) })
  prisma:engine       at NodeEngine.graphQLToJSError (C:\temp\prisma-issue\node_modules\@prisma\client\runtime\index.js:27156:14)
  prisma:engine       at NodeEngine.request (C:\temp\prisma-issue\node_modules\@prisma\client\runtime\index.js:27052:24)
  prisma:engine       at processTicksAndRejections (internal/process/task_queues.js:93:5)
  prisma:engine       at async cb (C:\temp\prisma-issue\node_modules\@prisma\client\runtime\index.js:78659:26)
  prisma:engine       at async main (C:\temp\prisma-issue\index.js:5:16) {
  prisma:engine     clientVersion: '2.17.0'
  prisma:engine   }
  prisma:engine }  
  prisma:engine stdout  Conversion failed when converting from a character string to uniqueidentifier.  
  prisma:engine {
  prisma:engine   error: PrismaClientUnknownRequestError2 [PrismaClientUnknownRequestError]: Error occurred during query execution:
  prisma:engine   ConnectorError(ConnectorError { user_facing_error: None, kind: QueryError(TokenError { code: 8169, state: 2, class: 16, message: "Conversion failed when converting from a character string to uniqueidentifier.", server: "MINIBEAST", procedure: "", line: 1 }) })
  prisma:engine       at NodeEngine.graphQLToJSError (C:\temp\prisma-issue\node_modules\@prisma\client\runtime\index.js:27156:14)
  prisma:engine       at NodeEngine.request (C:\temp\prisma-issue\node_modules\@prisma\client\runtime\index.js:27052:24)
  prisma:engine       at processTicksAndRejections (internal/process/task_queues.js:93:5)
  prisma:engine       at async cb (C:\temp\prisma-issue\node_modules\@prisma\client\runtime\index.js:78659:26)
  prisma:engine       at async main (C:\temp\prisma-issue\index.js:5:16) {
  prisma:engine     clientVersion: '2.17.0'
  prisma:engine   }
  prisma:engine }  

Client Snippet

const { PrismaClient } = require("@prisma/client");
async function main() {
  const client = new PrismaClient();
  await client.$connect();
  const data = await client.table.findMany({
    where: { Id: "test" },
  });
  console.log(data);
  client.$disconnect();
}
main();

Schema

model table {
  Id     String  @id @default(dbgenerated("newid()")) @db.UniqueIdentifier
  Value  Int
}

Prisma cannot handle the SQL error when trying to match a string to UniqueIdentifier

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
peteralbertcommented, Apr 1, 2021

Even better would be to have a proper uuid type so already you’d get an error in the client if your value is not a real guid.

That is what we ended up doing! We used https://github.com/NicolasDeveloper/guid-typescript to make sure, only valid GUIDs can be used.

1reaction
pantharshit00commented, Mar 10, 2021

I can reproduce the crash with above query and schema. Here is a packaged reproduction: https://github.com/harshit-test-org/prisma-issue-5869

We should look into this and fix it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Conversion failed when converting from a character string ...
The error message is Conversion failed when converting from a character string to uniqueidentifier. The GUIDs are the ones that I got when...
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 ...
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 character string ...
Table has unique identifier column and newid() was inserted into the table. error message is displayed. How's that?
Read more >
Conversion failed when converting from a character string ...
This error message appears when you try to convert an invalid character string to uniqueidentifier . Consequences: The T-SQL statement can be ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found