Skip to content

Conversation

@aleclarson
Copy link

Example error that is prevented by this PR:

ALTER TABLE "inquiry" ALTER COLUMN "mode" SET DATA TYPE "undefined"."inquiry_mode";
error: schema "undefined" does not exist
@aleclarson
Copy link
Author

aleclarson commented Aug 30, 2025

Temporary patch

diff --git a/api.js b/api.js
index 083cfed2ce284c2f2b17617f081d01621c9f87bc..be36e2a46a603d33ff3ec38e9438c185933c652e 100644
--- a/api.js
+++ b/api.js
@@ -13583,7 +13583,7 @@ WITH ${withCheckOption} CHECK OPTION` : "";
         const { tableName, columnName, newDataType, schema: schema5, oldDataType, columnDefault, typeSchema } = statement;
         const tableNameWithSchema = schema5 ? `"${schema5}"."${tableName}"` : `"${tableName}"`;
         const statements = [];
-        const type = parseType(`"${typeSchema}".`, newDataType.name);
+        const type = parseType(typeSchema ? `"${typeSchema}".` : "", newDataType.name);
         if (!oldDataType.isEnum && !newDataType.isEnum) {
           statements.push(
             `ALTER TABLE ${tableNameWithSchema} ALTER COLUMN "${columnName}" SET DATA TYPE ${type};`
diff --git a/api.mjs b/api.mjs
index a7942a40f88b7f87c5a5fe36d755862780dabde8..fbad8b671d4e352300b55764dbf24eae96708699 100644
--- a/api.mjs
+++ b/api.mjs
@@ -13588,7 +13588,7 @@ WITH ${withCheckOption} CHECK OPTION` : "";
         const { tableName, columnName, newDataType, schema: schema5, oldDataType, columnDefault, typeSchema } = statement;
         const tableNameWithSchema = schema5 ? `"${schema5}"."${tableName}"` : `"${tableName}"`;
         const statements = [];
-        const type = parseType(`"${typeSchema}".`, newDataType.name);
+        const type = parseType(typeSchema ? `"${typeSchema}".` : "", newDataType.name);
         if (!oldDataType.isEnum && !newDataType.isEnum) {
           statements.push(
             `ALTER TABLE ${tableNameWithSchema} ALTER COLUMN "${columnName}" SET DATA TYPE ${type};`
diff --git a/bin.cjs b/bin.cjs
index 8c3b0cdc75ca7ce5406f4f1f45fdd6b11249c637..d9f46d0b99e744771da22516f9a57e1db307e37e 100755
--- a/bin.cjs
+++ b/bin.cjs
@@ -25582,7 +25582,7 @@ WITH ${withCheckOption} CHECK OPTION` : "";
         const { tableName, columnName, newDataType, schema: schema6, oldDataType, columnDefault, typeSchema } = statement;
         const tableNameWithSchema = schema6 ? `"${schema6}"."${tableName}"` : `"${tableName}"`;
         const statements = [];
-        const type = parseType(`"${typeSchema}".`, newDataType.name);
+        const type = parseType(typeSchema ? `"${typeSchema}".` : "", newDataType.name);
         if (!oldDataType.isEnum && !newDataType.isEnum) {
           statements.push(
             `ALTER TABLE ${tableNameWithSchema} ALTER COLUMN "${columnName}" SET DATA TYPE ${type};`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant