Skip to content

fix mysql introspection json columns#1495

Open
aiprojectchiwa wants to merge 1 commit intoprisma:mainfrom
aiprojectchiwa:fix/mysql-introspection-json-string
Open

fix mysql introspection json columns#1495
aiprojectchiwa wants to merge 1 commit intoprisma:mainfrom
aiprojectchiwa:fix/mysql-introspection-json-string

Conversation

@aiprojectchiwa
Copy link
Copy Markdown

Summary

Fix MySQL/MariaDB introspection in Prisma Studio when the introspection query returns aggregated columns as a JSON string instead of an array.

This prevents Studio from crashing with errors like:

  • a.sort is not a function
  • columns.sort is not a function

Root cause

Some MySQL-compatible backends (notably MariaDB variants) can return the json_arrayagg(...) result as a string payload. The adapter assumed columns was always already an array and called .sort() directly.

Fix

  • Normalize columns before sorting
  • Parse JSON string payloads when needed
  • Keep the existing behavior unchanged for proper array results
  • Add a regression test covering the string-returning case

Verification

Validated on Node 24.13.0 with:

  • pnpm typecheck
  • pnpm exec eslint data/mysql-core/adapter.ts data/mysql-core/introspection-hardening.test.ts
  • pnpm test:data
  • pnpm build
  • pnpm check:exports

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant