pg-structure icon indicating copy to clipboard operation
pg-structure copied to clipboard

error: '3752' cannot be found in NormalFunction's oid

Open madflow opened this issue 1 year ago • 3 comments

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)

madflow avatar Jun 03 '24 17:06 madflow

Thank you @madflow for the report. I will examine the problem.

ozum avatar Jun 04 '24 13:06 ozum

I also encountered this today:

Screenshot_2024-09-04_at_15_35_52

Interestingly, it only happens when I pass includeSchemas: ['public'].

blimmer avatar Sep 04 '24 21:09 blimmer

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

blimmer avatar Sep 04 '24 22:09 blimmer