Skip to content

Instantly share code, notes, and snippets.

@larryonward
Created December 4, 2024 03:12
Show Gist options
  • Save larryonward/5c845651b9a9a64875864b7ddcfc7323 to your computer and use it in GitHub Desktop.
Save larryonward/5c845651b9a9a64875864b7ddcfc7323 to your computer and use it in GitHub Desktop.
hotfix for drizzle-orm 0.37.0, drizzle-kit 0.29.0
# TypeError: Cannot destructure property 'resourceArn' of 'connection' as it is undefined.
# fix: use other way to check if instance is RDSDataClient
sed -i '' 's/params\[0\] instanceof RDSDataClient/params\[0\].constructor.name === "RDSDataClient"/g' node_modules/drizzle-orm/aws-data-api/pg/driver.js
# Error: The result contains the unsupported data type "CHAR".
# fix: cast CHAR to TEXT
sed -i '' 's/const proxy = async (params) => {/const proxy = async (params) => {\n params.sql = params.sql.replace(\/a.attidentity AS identity_type\/i, '\''a.attidentity::text AS identity_type'\''); \n params.sql = params.sql.replace(\/a.attgenerated AS generated_type\/i, '\''a.attgenerated::text AS generated_type'\'');/g' node_modules/drizzle-kit/bin.cjs
sed -i '' 's/const proxy = async (params) => {/const proxy = async (params) => {\n params.sql = params.sql.replace(\/con.contype AS constraint_type\/i, '\''con.contype::text AS constraint_type'\'');/g' node_modules/drizzle-kit/bin.cjs
# ERROR: bind message supplies 0 parameters, but prepared statement \"sqlx_s_8\" requires 1; SQLState: 08P01
# fix: replaces all $1 $2 with :1 :2, e.g. 'limit $1 offset $2' => 'limit :1 offset :2'
sed -i '' 's/const proxy = async (params) => {/const proxy = async (params) => {\n params.sql = params.sql.replace(\/\\$(\\d)\/g, '\'':$1'\'');/g' node_modules/drizzle-kit/bin.cjs
@haypho
Copy link

haypho commented Feb 1, 2025

FYI: for those using Next.js with js minification, the constructor name will also be minified causing the "TypeError: Cannot destructure property 'resourceArn' of 'connection' as it is undefined." to appear again. I was able to get around this by changing the "RDSDataClient" string to RDSDataClient.name for the constructor name instead.

sed -i '' 's/params\[0\] instanceof RDSDataClient/params\[0\].constructor.name === RDSDataClient.name/g' node_modules/drizzle-orm/aws-data-api/pg/driver.js

Hope it helps!

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