drizzle-orm icon indicating copy to clipboard operation
drizzle-orm copied to clipboard

[BUG]: Cannot run drizzle-studio with DATA-API. Unsupported data type "CHAR"

Open valentinbeggiaxa opened this issue 1 year ago • 5 comments

Report hasn't been filed before.

  • [x] I have verified that the bug I'm about to report hasn't been filed before.

What version of drizzle-orm are you using?

0.41.0

What version of drizzle-kit are you using?

0.31.2

Other packages

No response

Describe the Bug

Hello, It was working fine yesterday but now when trying to run the studio, I'm getting this error.

Error: The result contains the unsupported data type "CHAR".

Error: The result contains the unsupported data type "CHAR". at H (https://local.drizzle.studio/index.js:24905:7222) at async Object.query (https://local.drizzle.studio/index.js:1505:2665) at async hti (https://local.drizzle.studio/index.js:866:337) at async Ani (https://local.drizzle.studio/index.js:1142:14404) at async pull (https://local.drizzle.studio/index.js:1505:3385)

I already had this bug some months ago https://github.com/drizzle-team/drizzle-orm/issues/3273

I managed to fix it by doing some postgres casting.

  const replacements = [
      // [/\bpg_class\.oid\b/g, 'pg_class.oid::text'],
  // pg_opclass
  [/\bpg_opclass\.oid\b/g, 'pg_opclass.oid::text'],
  // pg_depend
  [/\bpg_depend\.objid\b/g, 'pg_depend.objid::text'],
  [/\bdeptype\b/g, 'deptype::text'],
  // pg_constraint
  [/\bpg_constraint\.oid\b/g, 'pg_constraint.oid::text'],
  [/\bcontype\b/g, 'contype::text'],
  [/\bconfupdtype\b/g, 'confupdtype::text'],
  [/\bconfdeltype\b/g, 'confdeltype::text'],
  [/pg_get_constraintdef\(([^)]+)\)/g, 'pg_get_constraintdef($1)::text'],
  // pg_get_viewdef
  [/pg_get_viewdef\(([^)]+)\)/g, 'pg_get_viewdef($1)::text'],
  // pg_attribute
  [/\battgenerated\b/g, 'attgenerated::text'],
  [/\battidentity\b/g, 'attidentity::text'],
  // pg_get_serial_sequence — force oid::text
  [/pg_get_serial_sequence\(([^)]+)\)::regclass::oid\b/g, 'pg_get_serial_sequence($1)::regclass::oid::text'],
  // relkind
  [/\brelkind\b/g, 'relkind::text']
              ];

const safeSql = replacements.reduce(
    (sql, [pattern, replacement]) => sql.replace(pattern, replacement),
    params.sql
);

However, i'm getting new errors afterwards, related to unicity column expressions, which I did not manage to fix.

Generated public.catalog_adaptations.unicity_id columns missing expression: "{"seqId":null,"generation":null,"start":null,"increment":null,"max":null,"min":null,"cycle":"NO","expression":"\nCASE\n WHEN (company_id IS NOT NULL) THEN (((catalog_adaptation_measure_slug)::text || '#'::text) || (company_id)::text)\n ELSE (((catalog_adaptation_measure_slug)::text || '#'::text) || (user_id)::text)\nEND"}"

Thanks in advance,

valentinbeggiaxa avatar Jun 24 '25 12:06 valentinbeggiaxa

Getting the same error trying to open drizzle studio with our postgres db.

Apparently from simply reading pg_class or pg_namespace, where some fields are CHAR


                     Table "pg_catalog.pg_class"
       Column        |     Type     | Collation | Nullable | Default
---------------------+--------------+-----------+----------+---------
 oid                 | oid          |           | not null |
 relname             | name         |           | not null |
.....
 relpersistence      | "char"       |           | not null | <<< 🔴 Error
 relkind             | "char"       |           | not null | <<< 🔴 Error
...

francisco-11x avatar Jun 24 '25 20:06 francisco-11x

Also started seeing this issue today.

alextbok avatar Jun 25 '25 19:06 alextbok

Fixed.

RomanNabukhotnyi avatar Jun 26 '25 08:06 RomanNabukhotnyi

Thanks @RomanNabukhotnyi Out of curiosity, how was it fixed ? I see no release on your end and was assuming the bug came from changes in aws data-api ?

valentinbeggiaxa avatar Jun 26 '25 10:06 valentinbeggiaxa

@valentinbeggiaxa The problem was in the latest studio update, as the introspect changed there.

RomanNabukhotnyi avatar Jun 26 '25 18:06 RomanNabukhotnyi