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.

`Bytes` not allowed as `@id` field when using SQL Server

See original GitHub issue

Bug description

Prisma will not validate a schema that uses a Bytes @id field and a provider of sqlserver.

How to reproduce

  1. Use the sqlserver provider
  2. Add a model field with type Bytes and the @id attribute
  3. Run prisma generate

Expected behavior

Bytes @id fields are allowed in other providers and should be possible with SQL Server

Prisma information

generator client {
  provider        = "prisma-client-js"
}

datasource db {
  provider = "sqlserver"
  url      = "connection string"
}

model Foo {
  bar Bytes @id
}

Environment & setup

  • OS: macOS 13.0
  • Database: SQL Server
  • Node.js version: 18.7.0

Prisma Version

prisma                  : 4.5.0
@prisma/client          : 4.5.0
Current platform        : darwin-arm64
Query Engine (Node-API) : libquery-engine 0362da9eebca54d94c8ef5edd3b2e90af99ba452 (at node_modules/@prisma/engines/libquery_engine-darwin-arm64.dylib.node)
Migration Engine        : migration-engine-cli 0362da9eebca54d94c8ef5edd3b2e90af99ba452 (at node_modules/@prisma/engines/migration-engine-darwin-arm64)
Introspection Engine    : introspection-core 0362da9eebca54d94c8ef5edd3b2e90af99ba452 (at node_modules/@prisma/engines/introspection-engine-darwin-arm64)
Format Binary           : prisma-fmt 0362da9eebca54d94c8ef5edd3b2e90af99ba452 (at node_modules/@prisma/engines/prisma-fmt-darwin-arm64)
Format Wasm             : @prisma/prisma-fmt-wasm 4.5.0-43.0362da9eebca54d94c8ef5edd3b2e90af99ba452
Default Engines Hash    : 0362da9eebca54d94c8ef5edd3b2e90af99ba452
Studio                  : 0.476.0
Preview Features        : interactiveTransactions, fieldReference

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:2
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
Jolg42commented, Nov 4, 2022

On SQL Server 2019, the following is valid

CREATE TABLE testbinarykey (
	ID VARBINARY(64) NOT NULL, CONSTRAINT PK_testbinarykey_id PRIMARY KEY CLUSTERED (id)
)
npx prisma@dev db pull --url="sqlserver://localhost:1433;database=15986;user=SA;password=Pr1sm4_Pr1sm4;trustServerCertificate=true;"

but it results in an invalid schema (schema validation error) Screenshot 2022-11-04 at 12 53 33

datasource db {
  provider = "sqlserver"
  url      = "sqlserver://localhost:1433;database=15986;user=SA;password=Pr1sm4_Pr1sm4;trustServerCertificate=true;"
}

model testbinarykey {
  ID Bytes @id(map: "PK_testbinarykey_id") @db.VarBinary(64)
}
1reaction
Jolg42commented, Nov 4, 2022

I’ll try this in a bit to confirm it

Read more comments on GitHub >

github_iconTop Results From Across the Web

is of a type that is invalid for use as a key column in an index
The only solution is to use less data in your Unique Index. Your key can be NVARCHAR(450) at most. "SQL Server retains the...
Read more >
Maximum capacity specifications for SQL Server
This article shows maximum sizes and numbers of various objects defined in SQL Server components, along with additional information.
Read more >
How to solve the SQL Identity Crisis in SQL Server
This article gives an overview of SQL Identity crisis and method to resolve it.
Read more >
SQL Data Types for MySQL, SQL Server, and MS Access
String Data Types ; BINARY(size), Equal to CHAR(), but stores binary byte strings. The size parameter specifies the column length in bytes. Default...
Read more >
SQLSTATE values and common error codes - IBM
A triggered SQL statement failed. Table 8. Class Code 0A: Feature Not Supported. SQLSTATE Value, Meaning ...
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