Skip to content

[pull] main from prisma:main#212

Merged
pull[bot] merged 1 commit intocode:mainfrom
prisma:main
Feb 26, 2026
Merged

[pull] main from prisma:main#212
pull[bot] merged 1 commit intocode:mainfrom
prisma:main

Conversation

@pull
Copy link

@pull pull bot commented Feb 26, 2026

See Commits and Changes for more details.


Created by pull[bot] (v2.0.0-alpha.4)

Can you help keep this open source service alive? 💖 Please sponsor : )

…umns with binary collation in raw queries (#29238)

Fixes #29237

## Summary

### adapter-mariadb
Replace the `BINARY_FLAG` check with a collation index check
(`collation.index === 63`), matching the approach used by
`mariadb-connector-nodejs`.

https://github.com/mariadb-corporation/mariadb-connector-nodejs/blob/3.5.1/lib/cmd/decoder/text-decoder.js#L44

### adapter-planetscale
Add a charset-based collation check (`field.charset !== 63`) in
`fieldToColumnType` to distinguish text columns from true binary
columns. Vitess converts CHAR/VARCHAR/TEXT columns with a binary
collation to BINARY/VARBINARY/BLOB respectively, so the charset value is
used to detect this conversion.

https://github.com/planetscale/database-js/blob/de78eebfaec8cd88c670b8c644fc5a3fd69e664c/src/cast.ts#L92

## Root cause

Because the `mapColumnType` function in `adapter-mariadb` returns
`ColumnTypeEnum.Bytes` when a column has a Binary Collation,

https://github.com/prisma/prisma/blob/7.4.1/packages/adapter-mariadb/src/conversion.ts#L86

and the `fieldToColumnType` function in `adapter-planetscale` does not
inspect the charset at all for BLOB/BINARY/VARBINARY types,

https://github.com/prisma/prisma/blob/7.4.1/packages/adapter-planetscale/src/conversion.ts#L85

the `deserializeValue` function unintentionally converts even string
data into a `Uint8Array`, treating it as a base64 string.

https://github.com/prisma/prisma/blob/7.4.1/packages/client/src/runtime/utils/deserializeRawResults.ts#L20

Since a Binary Collation can also apply to string data types like
`CHAR`, the type determination logic in both `adapter-mariadb` and
`adapter-planetscale` needs to be updated.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Bug Fixes**
* Improved binary collation detection in MariaDB and PlanetScale
database adapters. Columns with binary collation now correctly return as
text data.

* **Tests**
* Added MySQL column type tests to validate binary collation handling in
query results.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
@pull pull bot locked and limited conversation to collaborators Feb 26, 2026
@pull pull bot added the ⤵️ pull label Feb 26, 2026
@pull pull bot merged commit 76bb95b into code:main Feb 26, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant