pg-structure
pg-structure copied to clipboard
error: '3752' cannot be found in NormalFunction's oid
This is a drive-by bug report. I am just toying around with this library. No expectations.
- Postgres 16
- Latest version of
pg-structure - Database structure: https://github.com/neondatabase/postgres-sample-dbs/blob/main/pagila.sql
import pgStructure from "pg-structure";
const db = await pgStructure(
{
database: "postgres",
user: "postgres",
password: "postgres",
},
{
includeSchemas: ["public"],
},
);
486 | get(value, { key = this.defaultKey, fromIndex = 0, throwUnknown = this._throwUnknown, } = {}) {
487 | const index = this.getIndex(value, { key, fromIndex });
488 | if (throwUnknown && index === -1) {
489 | const firstObjectElement = this.find((e) => typeof e === "object");
490 | const possibleType = firstObjectElement && `${firstObjectElement.constructor.name}'s `;
491 | throw new Error(`'${value}' cannot be found in ${possibleType || ""}${key}.`);
^
error: '3752' cannot be found in NormalFunction's oid.
at get (/pg-structure/node_modules/indexable-array/dist/index.js:491:19)
at /pg-structure/node_modules/pg-structure/dist/main.js:237:22
at forEach (:1:21)
at addTriggers (/pg-structure/node_modules/pg-structure/dist/main.js:235:5)
at addObjects (/pg-structure/dist/main.js:339:5)
at /pg-structure/node_modules/pg-structure/dist/main.js:378:5
Bun v1.1.10 (macOS arm64)
Thank you @madflow for the report. I will examine the problem.
I also encountered this today:
Interestingly, it only happens when I pass includeSchemas: ['public'].
Ah, @stephenh gave me a heads up - the issue is that a trigger is referencing a schema I didn't include in the includeSchemas array. That's also why it works when I don't specify includeSchemas.
Looks like this is a related issue: https://github.com/ozum/pg-structure/issues/85