Skip to content

Schema isn't included in queries when using TypedSQL in combination with Driver Adapter #26930

@theguacamoleking

Description

@theguacamoleking

Bug description

Hey there!

I've been playing around with TypedSQL and so far, it's been awesome! That being said, I'm now trying to use the Postgres driver adapter but this causes all TypedSQL queries to break.

PrismaClientKnownRequestError:
Invalid `prisma.$queryRawTyped()` invocation:

Raw query failed. Code: `42P01`. Message: `relation "MyTable" does not exist`

This is exclusive to TypedSQL queries. Typical ORM queries (prisma.myTable.findMany()) correctly make use of the schema.

Severity

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

Reproduction

Create a typedsql script

-- prisma/sql/myQuery.sql
SELECT * FROM "MyTable";

Run prisma, call script

// File.ts
const adapter = new PrismaPg(
  { connectionString: ...  },
  { schema: 'my_schema' }
);
const prisma = new PrismaClient({
  adapter,
});

// Run ORM query (works fine)
console.log(await prisma.myTable.findMany({ take: 1 }));

// Run typed sql query - errors
console.log(await prisma.$queryRawTyped(myQuery()))

Expected vs. Actual Behavior

Expected: Resulting TypedSQL query contains my_schema."MyTable"
Actual: Resulting TypedSQL query ignores any schema configuration

Frequency

Consistently reproducible

Does this occur in development or production?

Both development and production

Is this a regression?

Unknown

Workaround

No known workaround

Prisma Schema & Queries

N/A

Prisma Config

See repro above

Logs & Debug Info

See above

Environment & Setup

  • OS: macOS
  • Database: PostgreSQL
  • Node.js version: 23

Prisma Version

prisma                  : 6.6.0
@prisma/client          : 6.6.0
Computed binaryTarget   : darwin-arm64
Operating System        : darwin
Architecture            : arm64
Node.js                 : v23.8.0
TypeScript              : 5.8.2
Query Engine (Node-API) : libquery-engine f676762280b54cd07c770017ed3711ddde35f37a (at node_modules/@prisma/engines/libquery_engine-darwin-arm64.dylib.node)
Schema Engine           : schema-engine-cli f676762280b54cd07c770017ed3711ddde35f37a (at node_modules/@prisma/engines/schema-engine-darwin-arm64)
Schema Wasm             : @prisma/prisma-schema-wasm 6.6.0-53.f676762280b54cd07c770017ed3711ddde35f37a
Default Engines Hash    : f676762280b54cd07c770017ed3711ddde35f37a
Studio                  : 0.511.0
Preview Features        : driverAdapters, metrics, typedSql

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions