Prisma ORM compatibility issue: SQL parser fails with parameterized LIMIT/OFFSET clauses
Describe the bug
Summary: RisingWave's SQL parser fails to parse parameterized queries generated by Prisma ORM, specifically when LIMIT $n OFFSET $m parameters are used.
Environment:
RisingWave Version: [Your version] Prisma Version: [Your version, e.g., 5.x.x] Database: PostgreSQL-compatible Client: Node.js with Prisma Client Expected Behavior: Prisma ORM generated queries with parameterized LIMIT/OFFSET should execute successfully.
Actual Behavior: SQL parser error occurs with message: "sql parser error: expected a value, found: $3"
Reproducible Example:
Database Schema: CREATE TABLE wave.availableinventory_mv ( accountid VARCHAR, businessunitid VARCHAR, itemid VARCHAR, inventoryclass VARCHAR, inventorystatus VARCHAR, status VARCHAR, warehouseid VARCHAR, lotnumber VARCHAR, availablequantity DECIMAL, committedquantity DECIMAL );
Prisma Schema: generator client { provider = "prisma-client-js" }
datasource db { provider = "postgresql" url = "postgresql://user:pass@risingwave:4567/db?schema=wave" }
model availableinventory_mv { accountid String @id @db.VarChar() businessunitid String @db.VarChar() itemid String @db.VarChar() inventoryclass String @db.VarChar() inventorystatus String @db.VarChar() status String @db.VarChar() warehouseid String @db.VarChar() lotnumber String @db.VarChar() availablequantity Decimal? @db.Decimal() committedquantity Decimal? @db.Decimal() }
Failing Code: // This fails with RisingWave const result = await prisma.availableinventory_mv.findFirst({ where: { accountid: '01JY3C2KYS04J96F0Q1ZBHJ3PH' } });
Generated SQL (Failing):
SELECT "wave"."availableinventory_mv"."accountid", "wave"."availableinventory_mv"."businessunitid", "wave"."availableinventory_mv"."itemid", -- ... other fields FROM "wave"."availableinventory_mv" WHERE "wave"."availableinventory_mv"."accountid" = $1 LIMIT $2 OFFSET $3 ^^ -- Parser fails here
Error message/log
ConnectorError(ConnectorError {
user_facing_error: None,
kind: QueryError(PostgresError {
code: "XX000",
message: "Failed to prepare the statement\n\nCaused by:\n sql parser error: expected a value, found: $3\nLINE 1: ... LIMIT $2 OFFSET $3\n ^\n",
severity: "ERROR"
})
})
Root Cause Analysis:
Prisma ORM automatically adds LIMIT $n OFFSET $m clauses to queries
RisingWave's SQL parser doesn't handle parameterized LIMIT/OFFSET clauses
Direct SQL with literal values works fine
The issue affects all Prisma methods that generate LIMIT/OFFSET: findFirst(), findMany(), findUnique() with paginationTo Reproduce
No response
Expected behavior
No response
How did you deploy RisingWave?
No response
The version of RisingWave
No response
Additional context
No response
Source: risingwavelabs/risingwave