Skip to content

Prisma Studio fails when table contains a column named value (generates conflicting SQL column names) #1408

Closed as duplicate

Description

@chakrihacker

Bug description

Description

Prisma Studio generates an invalid SQL query when a table contains a column named value.
In my case, the verification table has a column called value, and Studio generates a WITH count AS (...) CTE that also contains a column named value.

This produces a conflict and Postgres returns an error because both the table and the CTE expose "value".


Query Generated by Prisma Studio

WITH "count" AS (
  SELECT CAST(COALESCE(count(*), 0) AS text) AS "value"
  FROM "public"."verification"
  WHERE TRUE
)
SELECT
  "value",
  "identifier",
  "id",
  "updatedAt",
  "createdAt",
  "expiresAt",
  "count"."value" AS "__ps_count__"
FROM "public"."verification", "count"
WHERE TRUE
LIMIT $1 OFFSET 0;

Error

Because both the table and the CTE define a "value" column, the query becomes ambiguous:

column reference "value" is ambiguous

Prisma Studio then fails to load the data for this model.


Expected Behavior

Prisma Studio should generate unambiguous SQL, for example:

  • Rename the CTE column (total_count instead of value), or
  • Alias the table column (verification.value AS verification_value)

Example valid version:

WITH count_cte AS (
  SELECT CAST(COALESCE(count(*), 0) AS text) AS total_count
  FROM "public"."verification"
)
SELECT
  v."value",
  v."identifier",
  v."id",
  v."updatedAt",
  v."createdAt",
  v."expiresAt",
  c.total_count AS "__ps_count__"
FROM "public"."verification" v
CROSS JOIN count_cte c
LIMIT $1 OFFSET 0;

Steps to Reproduce

  1. Create a table in PostgreSQL with a column named value
  2. Use Prisma Schema to map it (e.g., model Verification)
  3. Open Prisma Studio
  4. Studio tries to load the table and crashes
  5. Check logs → shows the invalid SQL above

Environment

  • Prisma Version: (you can fill this)
  • Prisma Studio Version: (auto-include from browser)
  • Database: PostgreSQL
  • OS: macOS
  • Query Engine: Default
  • Node Version: (optional)

Suggested Fix

Rename the CTE column to avoid collisions with existing column names — e.g. total_count, ps_count, etc.
Alternatively, prefix CTE columns to prevent naming conflicts.


Severity

🔹 Minor: Unexpected behavior, but does not block development

Reproduction

Provided necessary info

Expected vs. Actual Behavior

Check above

Frequency

Consistently reproducible

Does this occur in development or production?

Only in development (e.g., CLI tools, migrations, Prisma Studio)

Is this a regression?

No

Workaround

No workaround

Prisma Schema & Queries

// Add relevant schema.prisma snippet
// Add relevant Prisma Client query

Prisma Config

// Add your `prisma.config.ts`

Logs & Debug Info

// Debug logs here

Environment & Setup

  • OS:
  • Database:
  • Node.js version:

Prisma Version

// Prisma version output

Activity

  1. mohakchakraborty2004 commented on Nov 26, 2025

    @mohakchakraborty2004
  2. transferred this issue fromprisma/ormon Nov 27, 2025
  3. locked and limited conversation to collaborators on Nov 27, 2025
  4. igalklebanov commented on Nov 27, 2025

    @igalklebanov

    Hey 👋

    Duplicate of #1392.

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

    kind/bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions