[BUG]: `effect-postgres` `db.execute()` is typed as a row array but returns the `@effect/sql-pg` result object

Author: a9a4kCreated Sep 25, 2026Updated Sep 29, 2026
Labelsbug
  • I have verified that the bug I'm about to report hasn't been filed before.

drizzle-orm: 1.0.0-rc.4 (also checked the rc5 branch) drizzle-kit: 1.0.0-rc.4 Other packages: @effect/[email protected], [email protected]

Describe the Bug

In drizzle-orm/effect-postgres, db.execute() returns the raw driver result, { command, rowCount, oid, rows, fields }. That's intended: the rc.4 changelog says "Fixed @effect/sql-pg driver returning object response instead of raw response on db.execute" (116462b56b), and EffectPgSession.prepareQuery returns q.raw for 'raw' mode.

The type was not updated to match:

  • rc.4: EffectPgQueryResultHKT['type'] is readonly Assume<this['row'], object>[], so execute is typed as a row array that it never returns.
  • rc5 branch (4d12832d69): the type is now unknown, so reading result.rows doesn't compile without a cast.
typescript
import { PgClient } from '@effect/sql-pg';
import { sql } from 'drizzle-orm';
import * as PgDrizzle from 'drizzle-orm/effect-postgres';
import { Effect, Redacted } from 'effect';

const program = Effect.gen(function* () {
  const db = yield* PgDrizzle.makeWithDefaults();
  const result = yield* db.execute<{ one: number }>(sql`select 1 as one`);

  console.log(Array.isArray(result)); // false
  console.log(result.rows); // [{ one: 1 }] at runtime
  // rc.4: TS2339: Property 'rows' does not exist on type 'readonly { one: number; }[]'.
  // rc5:  'result' is of type 'unknown'.
});

Effect.runPromise(program.pipe(Effect.provide(PgClient.layer({ url: Redacted.make(process.env.DATABASE_URL!) }))));

The integration tests don't catch this because DB is typed as PgEffectDatabase<any, any, typeof relations> (integration-tests/tests/pg/effect-common.ts), so res.rows in the execute test type-checks against any.

Expected

execute should be typed as the result it returns, e.g.:

typescript
import type { Result } from '@effect/sql-pg/PgConnection';

export interface EffectPgQueryResultHKT extends PgQueryResultHKT {
  type: Omit<Result, 'rows'> & { readonly rows: readonly Assume<this['row'], object>[] };
}

We're using this as a local patch on rc.4, and it matches the runtime. A type-level assertion on db.execute<Row>() in the Effect tests, with a concretely typed DB, would catch this kind of drift.

Related

1.0.0-rc.4 declares effect: ">=4.0.0-beta.83", but it calls Schema.TaggedErrorClass, which [email protected] renamed to Schema.TaggedError. So importing drizzle-orm/effect-postgres with any current Effect v4 release throws TypeError: Schema.TaggedErrorClass is not a function. This is fixed on the rc5 branch (peer >=4.0.0-beta.105). Could this go out in a release before rc.5?

Source: drizzle-team/drizzle-orm