You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.31.0
What version of drizzle-kit are you using?
0.22.0
Other packages
No response
Describe the Bug
RDS Driver fails to insert array values into PostgreSQL
Issue Description
When using the AWS RDS Driver with Drizzle ORM, attempting to insert an array into PG columns fails with UUID parsing errors. This happens when trying to insert string arrays directly, empty arrays, or enum values. What did work was using sql.raw() with (string_to_array('${items.join(',')}', ',')::text[])
I haven't seen any issues on GH or discord about this, but I ran into it last night.
Hardcoding the value, which will be the same as what the sql.raw spits out, does work:
const items: (typeof items_table.$inferInsert)[] = MOCK_ITEMS.map((x) => {
return {
...x,
type: x. type,
//This is cursed AF, and its to make RDS work.
tags: sql`string_to_array('EXAMPLE,TEST', ',')::text[]`,
};
});
The following works:
const items: (typeof items_table.$inferInsert)[] = MOCK_ITEMS.map((x) => {
return {
...x,
type: x. type,
//This is cursed AF, and its to make RDS work.
tags: rdsArray(x. tags as ItemTag[]) as unknown as ItemTag[],
};
});
// Our function
function rdsArray(items: string[]): SQL<unknown> {
// We know this exact format works when used as a single literal
const fullSql = `string_to_array('${items.join(',')}', ',')::text[]`;
return sql.raw(fullSql);
}
The text was updated successfully, but these errors were encountered:
Report hasn't been filed before.
What version of
drizzle-orm
are you using?0.31.0
What version of
drizzle-kit
are you using?0.22.0
Other packages
No response
Describe the Bug
RDS Driver fails to insert array values into PostgreSQL
Issue Description
When using the AWS RDS Driver with Drizzle ORM, attempting to insert an array into PG columns fails with UUID parsing errors. This happens when trying to insert string arrays directly, empty arrays, or enum values. What did work was using sql.raw() with (
string_to_array('${items.join(',')}', ',')::text[]
)I haven't seen any issues on GH or discord about this, but I ran into it last night.
Example column and table definition:
The generated SQL from the migration file:
The generated SQL above didn't work. This casting change fixed that.
What didn't work
It gives this error:
It gives this error:
It gives this error:
What worked
Hardcoding the value, which will be the same as what the sql.raw spits out, does work:
The following works:
The text was updated successfully, but these errors were encountered: