Skip to content

Using "queryCompiler" with Postgresql Adapter $queryRaw fails with 'cannot read properties of undefined (reading 'length')' #27263

@ilmeskio

Description

@ilmeskio

Bug description

I am testing the new no rust engine feature ( as per https://www.prisma.io/docs/orm/prisma-client/setup-and-configuration/no-rust-engine ). I found a regression using $queryRaw

Cannot read properties of undefined (reading 'length')

following the stacktrace I suspect the issue comes from response deserialisation:

for (let i = 0; i < response.columns.length; i++) {

Related Issue: #27257

Severity

⚠️ Major: Breaks core functionality (e.g., migrations fail)

Reproduction

https://codesandbox.io/p/devbox/twilight-architecture-k924pv

can provide also a repository if needed.

In the sandbox you can reproduce using:

  • pnpm run reproduction1
  • pnpm run reproduction2
    or:
  • tsx src/rawQuerySelect1.ts
  • tsx src/rawQuerySelectUsers.ts

Expected vs. Actual Behavior

I expect to being able to execute $queryRaw. Note: even if not reproduced in the codesandbox also TypeSQL queries are involved in the bug.

In the actual behaviour using $queryRaw fails with Cannot read properties of undefined (reading 'length')

Frequency

Consistently reproducible

Does this occur in development or production?

Both development and production

Is this a regression?

Yes using postgresql adapter without the queryCompiler the bug does not reproduce

Workaround

do not use queryCompiler for $queryRaw or TypedSql

Prisma Schema & Queries

generator client {
    provider        = "prisma-client"
    output          = "../src/generated/prisma"
    previewFeatures = ["queryCompiler", "driverAdapters"]
    moduleFormat    = "esm"
}

datasource db {
    provider = "postgresql"
    url      = env("DATABASE_URL")
}

model Users {
    id                        String  @id @default(uuid(7)) @db.Uuid
    first_name                String
    last_name                 String
    email                     String  @unique
}
const connectionString =
  "postgresql://test:test@localhost:5432/test?schema=public";

const adapter = new PrismaPg({ connectionString });
const prisma = new PrismaClient({ adapter });
const result = await prisma.$queryRaw`SELECT 1`;

Prisma Config

// Add your `prisma.config.ts`

Logs & Debug Info

// Debug logs here

Environment & Setup

  • OS: macOS and Debian
  • Database: PostgreSQL
  • Node.js version: v20.12.1 and v22.14.0

Prisma Version

prisma                  : 6.8.2
@prisma/client          : 6.8.2
Computed binaryTarget   : debian-openssl-1.1.x
Operating System        : linux
Architecture            : x64
Node.js                 : v20.12.1
TypeScript              : 5.8.3
Query Engine (Node-API) : libquery-engine 2060c79ba17c6bb9f5823312b6f6b7f4a845738e (at node_modules/.pnpm/@[email protected]/node_modules/@prisma/engines/libquery_engine-debian-openssl-1.1.x.so.node)
Schema Engine           : schema-engine-cli 2060c79ba17c6bb9f5823312b6f6b7f4a845738e (at node_modules/.pnpm/@[email protected]/node_modules/@prisma/engines/schema-engine-debian-openssl-1.1.x)
Schema Wasm             : @prisma/prisma-schema-wasm 6.8.0-43.2060c79ba17c6bb9f5823312b6f6b7f4a845738e
Default Engines Hash    : 2060c79ba17c6bb9f5823312b6f6b7f4a845738e
Studio                  : 0.511.0
Preview Features        : driverAdapters, queryCompiler

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug/2-confirmedBug has been reproduced and confirmed.kind/bugA reported bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions