Repository navigation
Description
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_countinstead ofvalue), 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
- Create a table in PostgreSQL with a column named
value - Use Prisma Schema to map it (e.g., model
Verification) - Open Prisma Studio
- Studio tries to load the table and crashes
- 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 queryPrisma 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
mohakchakraborty2004 commentedon Nov 26, 2025
igalklebanov commentedon Nov 27, 2025
Hey 👋
Duplicate of #1392.