Summary
After v0.5.755 (cross-module ctor field-init persistence), drizzle's full insert chain still hits TypeError: Cannot read properties of undefined (reading 'run'). Bisecting reveals: (ins as any)._prepare is undefined even though _prepare is a regular method declaration on SQLiteInsertBase (line 140 of drizzle-orm/sqlite-core/query-builders/insert.js).
Repro
import { sqliteTable, integer, text } from "drizzle-orm/sqlite-core";
import Database from "better-sqlite3";
import { drizzle } from "drizzle-orm/better-sqlite3";
const sqlite = new Database(":memory:");
const db = drizzle(sqlite);
const users = sqliteTable("users", { id: integer("id").primaryKey(), name: text("name").notNull() });
sqlite.exec(`CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT NOT NULL)`);
const ins = db.insert(users).values([{ id: 1, name: "alice" }]);
console.log("ins.constructor[entityKind]:", (ins as any).constructor[Symbol.for("drizzle:entityKind")]);
// → "SQLiteInsert" ✓
console.log("typeof ins.run:", typeof (ins as any).run); // function ✓
console.log("typeof ins._prepare:", typeof (ins as any)._prepare); // undefined ✗ (Node: function)
console.log("typeof ins.prepare:", typeof (ins as any).prepare); // undefined ✗
console.log("typeof ins.execute:", typeof (ins as any).execute); // undefined ✗
console.log("typeof ins.returning:", typeof (ins as any).returning); // undefined ✗
ins.run(); // TypeError: Cannot read properties of undefined (reading 'run')
// ins.run is `(p) => this._prepare().run(p)`; _prepare returns undefined
Pattern
The class SQLiteInsertBase mixes:
- Arrow-function fields (
run = (p) => ..., all, get, values) — VISIBLE in Perry
- Method declarations (
_prepare(), prepare(), returning(), execute(), getSQL(), etc.) — UNDEFINED in Perry
Both should work via the vtable. Perry's PIC / property dispatch only finds the arrow-function fields (instance slots), not the prototype methods.
Bisection state
- v0.5.755 makes
sess.client/dialect/logger correctly set after super()
- Direct call also fails:
(ins as any)._prepare() returns undefined (not a "method not found" throw — just undefined return)
- Isolated repros with the same shape (extends from another module,
static [entityKind], mixed methods+fields, computed-key dispatch in body) all WORK in tests/release/packages/drizzle-sqlite or in /tmp/method_dispatch/. Something specific to drizzle's actual class registration (~100+ classes with shared inheritance) breaks this.
Acceptance
tests/release/packages/drizzle-sqlite/entry.ts produces output byte-identical to expected.txt.
Refs
Summary
After v0.5.755 (cross-module ctor field-init persistence), drizzle's full insert chain still hits
TypeError: Cannot read properties of undefined (reading 'run'). Bisecting reveals:(ins as any)._prepareisundefinedeven though_prepareis a regular method declaration onSQLiteInsertBase(line 140 ofdrizzle-orm/sqlite-core/query-builders/insert.js).Repro
Pattern
The class
SQLiteInsertBasemixes:run = (p) => ...,all,get,values) — VISIBLE in Perry_prepare(),prepare(),returning(),execute(),getSQL(), etc.) — UNDEFINED in PerryBoth should work via the vtable. Perry's PIC / property dispatch only finds the arrow-function fields (instance slots), not the prototype methods.
Bisection state
sess.client/dialect/loggercorrectly set after super()(ins as any)._prepare()returns undefined (not a "method not found" throw — just undefined return)static [entityKind], mixed methods+fields, computed-key dispatch in body) all WORK in tests/release/packages/drizzle-sqlite or in /tmp/method_dispatch/. Something specific to drizzle's actual class registration (~100+ classes with shared inheritance) breaks this.Acceptance
tests/release/packages/drizzle-sqlite/entry.tsproduces output byte-identical toexpected.txt.Refs
drizzle-ormend-to-end viaperry.compilePackages#420 / Function-static properties assigned via IIFE pattern (((fn) => { fn.method = ...; })(fn)) don't work — both same-module and cross-module #618 — drizzle Table chain