[BUG]: drizzle-kit push throws error: UnsupportedResultException: The result contains the unsupported data type regclass.
What version of drizzle-orm are you using?
0.24.2
What version of drizzle-kit are you using?
0.33.0
Describe the Bug
Running drizzle-kit push results in the error UnsupportedResultException: The result contains the unsupported data type regclass.
$ sst shell drizzle-kit push
No config path provided, using default 'drizzle.config.ts'
Reading config file '/home/the-simian/my-project/drizzle.config.ts'
[⣽] Pulling schema from database...
UnsupportedResultException: The result contains the unsupported data type regclass.
at de_UnsupportedResultExceptionRes (/home/the-simian/my-project/node_modules/@aws-sdk/client-rds-data/dist-cjs/index.js:1015:21)
at de_CommandError (/home/the-simian/my-project/node_modules/@aws-sdk/client-rds-data/dist-cjs/index.js:820:19)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async /home/the-simian/my-project/node_modules/@smithy/middleware-serde/dist-cjs/index.js:35:20
at async /home/the-simian/my-project/node_modules/drizzle-kit/bin.cjs:60552:22
at async /home/the-simian/my-project/node_modules/drizzle-kit/bin.cjs:60310:42
at async /home/the-simian/my-project/node_modules/drizzle-kit/bin.cjs:54122:26
at AwsDataApiPreparedQuery.values (/home/the-simian/my-project/node_modules/src/aws-data-api/pg/session.ts:111:18)
at AwsDataApiPreparedQuery.execute (/home/the-simian/my-project/node_modules/src/aws-data-api/pg/session.ts:61:18)
at AwsDataApiPreparedQuery.all (/home/the-simian/my-project/node_modules/src/aws-data-api/pg/session.ts:94:18) {
'$fault': 'client',
'$metadata': {
httpStatusCode: 400,
requestId: '8e194f6c-987e-49db-b18d-d72098bce953',
extendedRequestId: undefined,
cfId: undefined,
attempts: 1,
totalRetryDelay: 0
}
}
Expected behavior
I expect drizzle-kit to perform as it was in the past, and push the tables to the database without generating the migration file
Environment & setup
This is calling drizzle kit with AWS RDS posgres inside of an sst shell. You can see an example if this setup here: docs: https://sst.dev/docs/start/aws/drizzle example repo: https://github.com/sst/ion/tree/dev/examples/aws-drizzle
Here is a seemingly related issue with some troubleshooting from others https://github.com/drizzle-team/drizzle-kit-mirror/issues/544
- They are also using sst postgres with aws-data-api
- One user states that migrating past
"drizzle-orm": "~0.30.10",
"drizzle-kit": "~0.21.4",
I can verify this is true. Downgrading gets past this issue:
$ sst shell drizzle-kit push
drizzle-kit: v0.21.4
drizzle-orm: v0.30.10
No config path provided, using default path
Reading config file '/home/the-simian/my-project/lifeguides-application/drizzle.config.ts'
[✓] Pulling schema from database...[i] No changes detected
expresses the issue.
3. Another user removed regclass from this query and got the command to work https://github.com/drizzle-team/drizzle-orm/blob/main/drizzle-kit/src/serializer/pgSerializer.ts#L723
I took some time to zero in on when this broke, I think it was on the release of v0.23.0
release around 5/31
$ sst shell drizzle-kit push
drizzle-kit: v0.22.0
drizzle-orm: v0.31.0
No config path provided, using default path
Reading config file '/home/the-simian/my-project/drizzle.config.ts'
[✓] Pulling schema from database...[i] No changes detected
release around 6/29
$ sst shell drizzle-kit push
drizzle-kit: v0.22.8
drizzle-orm: v0.31.2
No config path provided, using default path
Reading config file '/home/the-simian/my-project/drizzle.config.ts'
[✓] Pulling schema from database...
[i] No changes detected
release around 7/10 💥kaboom💥
$ sst shell drizzle-kit push
drizzle-kit: v0.23.0
drizzle-orm: v0.32.0
No config path provided, using default path
Reading config file '/home/the-simian/my-project/drizzle.config.ts'
[⣯] Pulling schema from database...
UnsupportedResultException: The result contains the unsupported data type regclass.
at de_UnsupportedResultExceptionRes (/home/the-simian/my-project/node_modules/@aws-sdk/client-rds-data/dist-cjs/index.js:1015:21)
at de_CommandError (/home/the-simian/my-project/node_modules/@aws-sdk/client-rds-data/dist-cjs/index.js:820:19)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async /home/the-simian/my-project/node_modules/@smithy/middleware-serde/dist-cjs/index.js:35:20
at async /home/the-simian/my-project/node_modules/drizzle-kit/bin.cjs:60071:22
at async /home/the-simian/my-project/node_modules/drizzle-kit/bin.cjs:64123:42
at async /home/the-simian/my-project/node_modules/drizzle-kit/bin.cjs:57711:26
at AwsDataApiPreparedQuery.values (/home/the-simian/my-project/node_modules/src/aws-data-api/pg/session.ts:111:18)
at AwsDataApiPreparedQuery.execute (/home/the-simian/my-project/node_modules/src/aws-data-api/pg/session.ts:61:18)
at AwsDataApiPreparedQuery.all (/home/the-simian/my-project/node_modules/src/aws-data-api/pg/session.ts:94:18) {
'$fault': 'client',
'$metadata': {
httpStatusCode: 400,
requestId: '62dafe04-cc01-4840-b619-9631dd065275',
extendedRequestId: undefined,
cfId: undefined,
attempts: 1,
totalRetryDelay: 0
}
}
+1, also breaks when using pull
drizzle-kit: 0.28.0 drizzle-orm: 0.36.1
@ekaya97 thank you for that update, you just saved me a lot of time testing. Can't wait for some work on this issue, it looks like its been tagged by the Drizzle team, which is awesome.
+1 getting this issue.
drizzle-kit: 0.30.5 drizzle-orm: 0.41.0
Is there actually a workaround beyond downgrading to before the issue? Doing a new project and it seems the working version is quite a few versions behind and I'd rather not downgrade that far...
@LaurenceGA Unfortunately, I have tried patches but with no luck. I've pinned my deps at
"drizzle-kit": "0.22.0",
"drizzle-orm": "0.31.0",
There is the occasional frustration. Enums require manual migrations when they're in a different order, for instance. I periodically come across issues that have been solved on the main branch. These seems to be RDS specific, so I'm not sure how high prio they are to the drizzle team. I also use two patches on drizzle as well to prevent some small issues:
- patch drizzle-kit.
drizzle-kit+0.22.0.patch
diff --git a/node_modules/drizzle-kit/bin.cjs b/node_modules/drizzle-kit/bin.cjs
index 9a93653..d4c61ad 100755
--- a/node_modules/drizzle-kit/bin.cjs
+++ b/node_modules/drizzle-kit/bin.cjs
@@ -119591,6 +119591,9 @@ var init_connections = __esm({
return result;
};
const proxy = async (params) => {
+ params.sql = params.sql.replace(/a.attidentity AS identity_type/i, 'a.attidentity::text AS identity_type');
+ params.sql = params.sql.replace(/a.attgenerated AS generated_type/i, 'a.attgenerated::text AS generated_type');
+ params.sql = params.sql.replace(/con\.contype AS constraint_type/i, 'con.contype::text AS constraint_type');
const prepared = session.prepareQuery(
{
sql: params.sql,
@@ -119632,6 +119635,9 @@ var init_connections = __esm({
return result.rows;
};
const proxy = async (params) => {
+ params.sql = params.sql.replace(/a.attidentity AS identity_type/i, 'a.attidentity::text AS identity_type');
+ params.sql = params.sql.replace(/a.attgenerated AS generated_type/i, 'a.attgenerated::text AS generated_type');
+ params.sql = params.sql.replace(/con\.contype AS constraint_type/i, 'con.contype::text AS constraint_type');
const result = await client.query({
text: params.sql,
values: params.params,
@@ -119658,6 +119664,9 @@ var init_connections = __esm({
return result;
};
const proxy = async (params) => {
+ params.sql = params.sql.replace(/a.attidentity AS identity_type/i, 'a.attidentity::text AS identity_type');
+ params.sql = params.sql.replace(/a.attgenerated AS generated_type/i, 'a.attgenerated::text AS generated_type');
+ params.sql = params.sql.replace(/con\.contype AS constraint_type/i, 'con.contype::text AS constraint_type');
if (params.mode === "object") {
return await client.unsafe(params.sql, params.params);
}
@@ -119689,6 +119698,9 @@ var init_connections = __esm({
return result.rows;
};
const proxy = async (params) => {
+ params.sql = params.sql.replace(/a.attidentity AS identity_type/i, 'a.attidentity::text AS identity_type');
+ params.sql = params.sql.replace(/a.attgenerated AS generated_type/i, 'a.attgenerated::text AS generated_type');
+ params.sql = params.sql.replace(/con\.contype AS constraint_type/i, 'con.contype::text AS constraint_type');
const result = await client.query({
text: params.sql,
values: params.params,
@@ -119724,6 +119736,9 @@ var init_connections = __esm({
return result.rows;
};
const proxy = async (params) => {
+ params.sql = params.sql.replace(/a.attidentity AS identity_type/i, 'a.attidentity::text AS identity_type');
+ params.sql = params.sql.replace(/a.attgenerated AS generated_type/i, 'a.attgenerated::text AS generated_type');
+ params.sql = params.sql.replace(/con\.contype AS constraint_type/i, 'con.contype::text AS constraint_type');
const result = await client.query({
text: params.sql,
values: params.params,
@@ -119775,6 +119790,9 @@ var init_connections = __esm({
return res[0];
};
const proxy = async (params) => {
+ params.sql = params.sql.replace(/a.attidentity AS identity_type/i, 'a.attidentity::text AS identity_type');
+ params.sql = params.sql.replace(/a.attgenerated AS generated_type/i, 'a.attgenerated::text AS generated_type');
+ params.sql = params.sql.replace(/con\.contype AS constraint_type/i, 'con.contype::text AS constraint_type');
const result2 = await connection2.query({
sql: params.sql,
values: params.params,
@@ -119803,6 +119821,9 @@ var init_connections = __esm({
return res.rows;
};
const proxy = async (params) => {
+ params.sql = params.sql.replace(/a.attidentity AS identity_type/i, 'a.attidentity::text AS identity_type');
+ params.sql = params.sql.replace(/a.attgenerated AS generated_type/i, 'a.attgenerated::text AS generated_type');
+ params.sql = params.sql.replace(/con\.contype AS constraint_type/i, 'con.contype::text AS constraint_type');
const result2 = params.mode === "object" ? await connection2.execute(params.sql, params.params) : await connection2.execute(params.sql, params.params, {
as: "array"
});
- patch drizzle orm
drizzle-orm+0.31.0.patch
diff --git a/node_modules/drizzle-orm/aws-data-api/pg/driver.js b/node_modules/drizzle-orm/aws-data-api/pg/driver.js
index 7d47bf5..920ee81 100644
--- a/node_modules/drizzle-orm/aws-data-api/pg/driver.js
+++ b/node_modules/drizzle-orm/aws-data-api/pg/driver.js
@@ -45,6 +45,7 @@ class AwsPgDialect extends PgDialect {
}
}
function drizzle(client, config) {
+
const dialect = new AwsPgDialect();
let logger;
if (config.logger === true) {
diff --git a/node_modules/drizzle-orm/aws-data-api/pg/session.cjs b/node_modules/drizzle-orm/aws-data-api/pg/session.cjs
index 5ffcd99..b4b2212 100644
--- a/node_modules/drizzle-orm/aws-data-api/pg/session.cjs
+++ b/node_modules/drizzle-orm/aws-data-api/pg/session.cjs
@@ -91,6 +91,7 @@ class AwsDataApiPreparedQuery extends import_pg_core.PgPreparedQuery {
}
async values(placeholderValues = {}) {
const params = (0, import_sql.fillPlaceholders)(this.params, placeholderValues ?? {});
+ this.rawQuery.input.sql = this.rawQuery.input.sql.replace('$1', ':1');
this.rawQuery.input.parameters = params.map((param, index) => ({
name: `${index + 1}`,
...(0, import_common.toValueParam)(param, this.typings[index])
diff --git a/node_modules/drizzle-orm/aws-data-api/pg/session.js b/node_modules/drizzle-orm/aws-data-api/pg/session.js
index 59e63a9..81331b8 100644
--- a/node_modules/drizzle-orm/aws-data-api/pg/session.js
+++ b/node_modules/drizzle-orm/aws-data-api/pg/session.js
@@ -75,6 +75,7 @@ class AwsDataApiPreparedQuery extends PgPreparedQuery {
}
async values(placeholderValues = {}) {
const params = fillPlaceholders(this.params, placeholderValues ?? {});
+ this.rawQuery.input.sql = this.rawQuery.input.sql.replace('$1', ':1');
this.rawQuery.input.parameters = params.map((param, index) => ({
name: `${index + 1}`,
...toValueParam(param, this.typings[index])
So to be clear, I lock the versions and use patch-package with those specific files. I periodically try upgrading with no success. Like you, I also cannot wait until (I assume) the rds driver is fixed; because it would be great to be caught up with the recent work.
Thanks for your reply.
That's annoying. Maybe I'll just either keep off the data API or keep off drizzle for now then, doesn't seem Drizzle+RDS data API are really ready yet.
This issue started happening to me with [email protected] and [email protected] with error: UnsupportedResultException: The result contains the unsupported data type "CHAR".
@alextbok was it working with a later version than what I pinned at? is this something that was fixed, then working then fixed again? I wouldn't mind advancing my dependencies. Also, did you need to use my patches?
@AndriiSherman could anyone from the team acknowledge this? I have the same error with the latest version while running drizzle-kit introspect.
Hey everyone!
I've created this message to send in a batch to all opened issues we have, just because there are a lot of them and I want to update all of you with our current work, why issues are not responded to, and the amount of work that has been done by our team over ~8 months.
I saw a lot of issues with suggestions on how to fix something while we were not responding – so thanks everyone. Also, thanks to everyone patiently waiting for a response from us and continuing to use Drizzle!
We currently have 4 major branches with a lot of work done. Each branch was handled by different devs and teams to make sure we could make all the changes in parallel.
First branch is drizzle-kit rewrite
All of the work can be found on the alternation-engine branch. Here is a PR with the work done: https://github.com/drizzle-team/drizzle-orm/pull/4439
As you can see, it has 167k added lines of code and 67k removed, which means we've completely rewritten the drizzle-kit alternation engine, the way we handle diffs for each dialect, together with expanding our test suite from 600 tests to ~9k test units for all different types of actions you can do with kit. More importantly, we changed the migration folder structure and made commutative migrations, so you won't face complex conflicts on migrations when working in a team.
What's left here:
- We are finishing handling defaults for Postgres, the last being geometry (yes, we fixed the
sridissue here as well). - We are finishing commutative migrations for all dialects.
- We are finishing up the command, so the migration flow will be as simple as
drizzle-kit upfor you.
Where it brings us:
- We are getting drizzle-kit into a new good shape where we can call it
[email protected]!
Timeline:
- We need ~2 weeks to finish all of the above and send this branch to beta for testing.
Second big branch is a complex one with several HUGE updates
- Bringing Relational Queries v2 finally live. We've done a lot of work here to actually make it faster than RQBv1 and much better from a DX point of view. But in implementing it, we had to make another big rewrite, so we completely rewrote the drizzle-orm type system, which made it much simpler and improved type performance by ~21.4x:
(types instantiations for 3300 lines production drizzle schema + 990 lines relations)
TS v5.8.3: 728.8k -> 34.1k
TS v5.9.2: 553.7k -> 25.4k
You can read more about it here.
What's left here:
- We have 1 issue with TS that is already in progress of being fixed. The issue and Post about fixing.
Where it brings us:
- We are getting drizzle-orm into a new good shape where we can call it
[email protected]!
Breaking changes:
- We will have them, but we will have open channels for everyone building on top of drizzle types, so we can guide you through all the changes.
Third branch is adding support for CockroachDB and MSSQL dialects
Support for them is already in the alternation-engine branch and will be available together with the drizzle-kit rewrite.
Summary
All of the work we are doing is crucial and should be done sooner rather than later. We've received a lot of feedback and worked really hard to find the best strategies and decisions for API, DX, architecture, etc., so we can confidently mark it as v1 and be sure we can improve it and remain flexible for all the features you are asking for, while becoming even better for everyone building on top of the drizzle API as well.
We didn't want to stay with some legacy decisions and solutions we had, and instead wanted to shape Drizzle in a way that will be best looking ahead to 2025–2026 trends (v1 will get proper effect support, etc.).
We believe that all of the effort we've put in will boost Drizzle and benefit everyone using it.
Thanks everyone, as we said, we are here to stay for a long time to build a great tool together!
Timelines
We are hoping to get v1 for drizzle in beta this fall and same timeline for latest. Right after that we can go through all of the issues and PRs and resond everyone. v1 for drizzle should close ~70% of all the bug tickets we have, so on beta release we will start marking them as closed!
I'm still facing similar problem
any update?
I am also facing the same issue and the temporary work around I am using currently is that I use
Version:
[email protected] [email protected]
to generate migrations and switch to
[email protected] [email protected]
when I run the drizzle-kit push command
I couldn't find any work around to fully switch to the latest version or at least [email protected] [email protected] for generating and pushing migrations to my database.
I am still experiencing this. I should also add that I've had to pin several dependencies as a side effect, the reason being that this version of drizzle uses smithy v3, and when AWS deps move to v4 - you cannot advance. So, in short. Lock AWS deps like this:
"@aws-sdk/client-amplify": "3.928.0",
"@aws-sdk/client-bedrock": "3.928.0",
"@aws-sdk/client-dynamodb": "3.928.0",
"@aws-sdk/client-rds-data": "3.928.0",
"@aws-sdk/client-s3": "3.928.0",
"@aws-sdk/client-ses": "3.928.0",
"@aws-sdk/client-sqs": "3.928.0",
...etc. don't go past 3.928.0
Lock drizzle to:
"drizzle-kit": "0.22.0",
"drizzle-orm": "0.31.0",
"drizzle-zod": "0.5.1",
I have been periodically checking if I can advance these deps. Currently no - you can't. This may change, but currently no.
Hey everyone!
Thanks for reporting this and for providing the details
I followed the tutorial shared by @the-simian:
This is calling drizzle kit with AWS RDS posgres inside of an sst shell. You can see an example if this setup here: docs: https://sst.dev/docs/start/aws/drizzle example repo: https://github.com/sst/ion/tree/dev/examples/aws-drizzle
But I was not able to reproduce the issue
I tested several different versions and they all worked as expected
- orm: 0.33.0, 0.32.0, 0.28.0, 0.44.0
- kit: 0.24.2, 0.23.0, 0.36.1, 0.31.0
I would really appreciate it if anyone could share a minimal reproducible example. That would help us investigate issue further Thanks in advance!
P.S. Drizzle Kit has gone through a major rewrite, so you could also try using [email protected] and [email protected] (This is the latest beta release)
@AleksandrSherman you asked for a minimal reproducible example, and you suggested trying 1.0.0-rc.4. I did both. Here is everything, and then I am closing this issue.
Reproduction: simiancraft/drizzle-kit-rds-data-api-repro. Two branches, so the lines can be compared directly: main pins the stable line, rc pins 1.0.0-rc.4.
Headline: 1.0.0-rc.4 fixes it. Anyone landing here from a search who is stuck on 0.31.10, which is still latest on npm, will still hit it, so the workaround is written out below.
Why it did not reproduce for you
I pointed at the SST aws-drizzle example, which was the wrong artifact to hand you: its schema is a single trivial table. Every failure here comes from a catalog column that only appears in an introspection result set once the schema contains the feature that produces it:
| Failing expression | Postgres type | Requires in the schema |
|---|---|---|
con.contype |
"char" |
at least one constraint |
a.attidentity, a.attgenerated |
"char" |
any column |
pg_get_serial_sequence(...) |
regclass |
a serial / bigserial / identity column |
$1, $2 in the composite PK lookup |
n/a | a composite primary key |
So "I tested several versions and they all worked" and "this has been broken for years" are both true, of different schemas. The reproduction condition was never the version pair; it is whether the result set contains a char or regclass column, or whether the query carries positional parameters. The repro's schema is built to contain each trigger and nothing else.
(Small thing, in case it matters for your notes: the list reads orm: 0.33.0, 0.32.0, 0.28.0, 0.44.0 and kit: 0.24.2, 0.23.0, 0.36.1, 0.31.0, but 0.24.2 and 0.36.1 look like kit versions and 0.33.0 like an orm version, so the two lines may have been swapped.)
What I tested
Aurora Serverless v2, PostgreSQL 15.12, Data API enabled, against a dedicated empty database. The repro's catalog is created with plain DDL over the Data API rather than with drizzle-kit, so the tool under test is isolated from the fixture that produces its input. Each failing expression is probed on its own, paired with the same query plus a cast.
0.31.10 (npm latest) |
1.0.0-rc.4 |
|
|---|---|---|
pull / push introspection |
exit 1 | works |
| error reporting on failure | prints nothing | prints failing query + stack |
char result columns (contype, attidentity, attgenerated) |
rejected | fixed (::text) |
regclass result column (pg_get_serial_sequence) |
rejected | fixed (::regclass::oid) |
| composite PK column order | n/a | correct |
| multi-column FK pairing | n/a | correct |
| empty array default | n/a | correct |
studio proxy, positional params |
not tested (pull fails first) |
still fails |
The rc gets those casts right in dialects/postgres/aws-introspect.ts, which also uses no positional parameters at all; that is why pull no longer trips the binding defect below.
I checked correctness, not just exit status, because three of those defects corrupt output silently instead of raising; the schema is built so each would show. pull on 1.0.0-rc.4 is also clean against a real 43 table, 384 column, 100 index, 62 foreign key schema.
Two corrections to things I said earlier in this thread. The silent failure is fixed on the rc, which now reports the failing query and a stack trace. And I previously suggested pinning every @aws-sdk/* client to 3.928.0; that is broader than necessary and I would not repeat it. Only @aws-sdk/client-rds-data needs pinning on the 0.31.x line, because kit bundles part of its Data API client construction and pairs it with the app-installed command classes; a 3.1113-era @smithy/core changes the middleware contract and surfaces as serializerMiddleware is not found before any request reaches AWS.
What is still open
One defect can still be reproduced on 1.0.0-rc.4: drizzle-kit forwards Postgres positional $N placeholders to the Data API, which binds named parameters only, so studio cannot run a parameterized query. I filed this separately, with its own control-isolated reproduction on the rc branch of the same repo, since it is a different code path from what this issue reports. Didn't want to cross the streams.
- Issue: #6147
- Fix: #6148, against
beta. Rewrites$Nto:NbeforeprepareQueryin the Data APIqueryandproxywith a literal-aware scanner, so dollar signs inside comments, strings, dollar-quoted bodies, and identifiers are untouched. Unit tested, with no database required to run them.
Related: #2372 reports the same underlying incompatibility reached through push on a composite primary key, diagnosed there by @petejodo in January 2025. Its reported symptom is fixed on the rc, but the defect underneath is not.
If you are another AWS user, and you are reading this because you hit this exact issue:
here's my updated advice as of this moment:
On 1.0.0-rc.4: you are fine for pull and push. If you need studio, apply the diff from #6148 until it merges; it is three lines in cli/connections.ts plus one new file.
On 0.31.10 (npm latest): you need all of the following.
- Pin
@aws-sdk/client-rds-datato3.928.0. Other@aws-sdk/*clients can float. - Patch kit's introspection to cast the rejected result columns:
contype::text,attidentity::text,attgenerated::text, andpg_get_serial_sequence(...)::regclass::text. - Patch
$Nto:Nin kit's Data APIqueryandproxy. The rewrite must be literal aware or it corrupts dollar signs inside strings, dollar-quoted bodies, comments, and identifiers;foo$1is one identifier, notfoofollowed by$1. The implementation in #6148 is the one I use.
Closing this as resolved in 1.0.0-rc.4. Thanks to @ekaya97, @LaurenceGA, @alextbok, @gshpychka, @hiddehe, @matsuby, and @imukeshsoni for the corroborating reports over the years; the version data points made the window easy to identify. And thanks for the rc pointer, which turned out to be the actual answer.