Skip to content

$queryRaw ignores schema when using @prisma/adapter-pg #24660

Closed as not planned

Description

@rstreefland

Hi, I've been experimenting using the new driverAdapters preview feature with @prisma/adapter-pg so I can use oauth2 token login for Google Cloud SQL which is not currently supported out of the box by prisma.

Our database does not use the public schema, rather it uses one called staging. When using the built in prisma queries, they succeed as expected. However, when I use $queryRaw, raw queries that previously didn't need to be prepended with the schema now fail.

This is my code to instantiate the prisma client:

import { PrismaPg } from "@prisma/adapter-pg";
import { PrismaClient } from "@prisma/client";
import { GoogleAuth } from "google-auth-library";
import { Pool } from "pg";

const auth = new GoogleAuth({
  scopes: ["https://www.googleapis.com/auth/sqlservice.login"],
});

const pool = new Pool({
  host: "/cloudsql/REDACTED",
  user: "REDACTED",
  password: async (): Promise<string> => {
    return (await auth.getAccessToken()) as string;
  },
  database: "uat",
  ssl: false,
  idleTimeoutMillis: 0,
  max: 5,
});

const adapter = new PrismaPg(pool, {
  schema: "staging",
});

export const prismaClient = new PrismaClient({
  adapter,
  log: ["info", "warn", "error"],
});

This raw query works without the PrismaPg adapter, but fails when I use the adapter:

 await prismaClient.$queryRaw`select * from "AccountingPeriod" limit 1`;

It produces these logs:
Screenshot 2024-06-27 at 10 40 29

This raw query succeeds when using the PrismaPg adapter:

 await prismaClient.$queryRaw`select * from staging."AccountingPeriod" limit 1`;

I'm happy to provide more information if needed!

Activity

  1. added
    bug/1-unconfirmed
    kind/bug
    topic: raw
    tech/engines
    on Jun 29, 2024
  2. FGoessler commented on Jan 23, 2025

    @FGoessler
    Contributor

    Hi,

    We’ve noticed there hasn’t been activity on this issue for quite some time, and we suspect it might no longer be relevant. As part of our ongoing effort to streamline open issues in this repository, we’re closing this one to focus on what’s most important to our community.

    If you believe this issue is still relevant and requires attention, feel free to reopen it. Reopening the issue is a valuable signal to us about what matters most to you.

    You can learn more about our approach and motivations in the Prisma ORM Manifesto.

    With love,
    Your Prisma ORM Team ❤️

  3. jan-wilhelm commented on Sep 2, 2025

    @jan-wilhelm

    This is still an issue!

  4. ofabricio25 commented on Jan 2, 2026

    @ofabricio25

    I had same issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug/1-unconfirmedkind/bugtech/enginestopic: driverAdapterstopic: raw

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions