Skip to content

[BUG]: #5525

@sspilleman

Description

@sspilleman

Report hasn't been filed before.

  • 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.45.1

What version of drizzle-kit are you using?

0.31.10

Other packages

pg@^8.20.0

Describe the Bug

I have an existing local PostgreSQL database. I'm trying to generate a schema for it using npx drizzle-kit pull.

I am getting the following output:

Reading config file '/Volumes/Data/Nextcloud/Development/Deno/drizzle/f1db/drizzle.config.ts'
Pulling from ['public'] list of schemas

Using 'pg' driver for database querying
[✓] 32  tables fetched
[⣟] 399 columns fetching
[✓] 0   enums fetched
[⣟] 0   indexes fetching
[⣟] 7   foreign keys fetching
[✓] 0   policies fetched
[⣟] 0   check constraints fetching
[⣟] 0   views fetching
/Volumes/Data/Nextcloud/Development/Deno/drizzle/f1db/node_modules/.deno/drizzle-kit@0.31.10/node_modules/drizzle-kit/bin.cjs:18309
      const isArray = ((_b = (_a2 = internals == null ? void 0 : internals.tables[tableName]) == null ? void 0 : _a2.columns[columnName]) == null ? void 0 : _b.isArray) ?? false;
                                                                                                                            ^

TypeError: Cannot read properties of undefined (reading 'id')
    at defaultForColumn (/Volumes/Data/Nextcloud/Development/Deno/drizzle/f1db/node_modules/.deno/drizzle-kit@0.31.10/node_modules/drizzle-kit/bin.cjs:18309:125)
    at /Volumes/Data/Nextcloud/Development/Deno/drizzle/f1db/node_modules/.deno/drizzle-kit@0.31.10/node_modules/drizzle-kit/bin.cjs:17925:36
    at process.processTicksAndRejections (node:internal/process/task_queues:104:5)

Node.js v25.8.1

I added console.log(internals.tables, tableName, internals.tables[tableName]); for your help / reference.
output: {} constructor [Function: Object]

SQL of first table it fails on:

-- ----------------------------
-- Table structure for constructor
-- ----------------------------
DROP TABLE IF EXISTS "public"."constructor";
CREATE TABLE "public"."constructor" (
  "id" text COLLATE "pg_catalog"."default" NOT NULL,
  "name" text COLLATE "pg_catalog"."default",
  "full_name" text COLLATE "pg_catalog"."default",
  "country_id" text COLLATE "pg_catalog"."default",
  "best_championship_position" int8,
  "best_starting_grid_position" int8,
  "best_race_result" int8,
  "best_sprint_race_result" int8,
  "total_championship_wins" int8,
  "total_race_entries" int8,
  "total_race_starts" int8,
  "total_race_wins" int8,
  "total_1_and_2_finishes" int8,
  "total_race_laps" int8,
  "total_podiums" int8,
  "total_podium_races" int8,
  "total_points" numeric(8,2),
  "total_championship_points" numeric(8,2),
  "total_pole_positions" int8,
  "total_fastest_laps" int8,
  "total_sprint_race_starts" int8,
  "total_sprint_race_wins" int8
)
;
ALTER TABLE "public"."constructor" OWNER TO "f1db";

-- ----------------------------
-- Indexes structure for table constructor
-- ----------------------------
CREATE INDEX "idx_19612_cnst_country_id_idx" ON "public"."constructor" USING btree (
  "country_id" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "idx_19612_cnst_full_name_idx" ON "public"."constructor" USING btree (
  "full_name" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "idx_19612_cnst_name_idx" ON "public"."constructor" USING btree (
  "name" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);

-- ----------------------------
-- Primary Key structure for table constructor
-- ----------------------------
ALTER TABLE "public"."constructor" ADD CONSTRAINT "idx_19612_sqlite_autoindex_constructor_1" PRIMARY KEY ("id");

-- ----------------------------
-- Foreign Keys structure for table constructor
-- ----------------------------
ALTER TABLE "public"."constructor" ADD CONSTRAINT "constructor_country_id_fkey" FOREIGN KEY ("country_id") REFERENCES "public"."country" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingbug/fixed-in-betaThis bug has been fixed in beta (or will be soon).

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions