-
Notifications
You must be signed in to change notification settings - Fork 233
Open
Description
PGLite search_path Issue in Ponder Dev Mode
Summary
Raw SQL queries return 0 rows in ponder dev mode (PGLite) while Drizzle ORM queries work correctly. This affects @ponder/client SQL HTTP endpoints.
Environment
- ponder: 0.15.17
- Mode: dev (PGLite)
What works
- Drizzle ORM queries via
db.select().from(schema.table) - Production with Postgres
What fails
- Raw SQL via
db.execute(sqlSELECT * FROM "TableName")returns 0 rows @ponder/clientSQL HTTP endpoints return 0 rows
Root cause
PGLite's default search_path doesn't resolve unqualified table names to the public schema.
Drizzle ORM internally uses schema-qualified names, so it works. Raw SQL doesn't, so it fails silently.
Reproduction
// src/api/index.ts
import { db } from 'ponder:api'
import schema from 'ponder:schema'
import { count, sql } from 'ponder'
// This works - returns correct count
const drizzleResult = await db.select({ count: count() }).from(schema.myTable)
// This fails - returns 0
const rawResult = await db.execute(sql`SELECT COUNT(*) FROM "MyTable"`)
// This works - explicit schema
const fixedResult = await db.execute(sql`SELECT COUNT(*) FROM public."MyTable"`)Workaround
Use schema-qualified table names in raw SQL:
SELECT * FROM public."TableName"Why it's confusing
- Drizzle queries work fine
- Raw SQL fails silently (empty results, no error)
- Same code works in production with Postgres
@ponder/clientuses raw SQL internally, so all client queries returns empty
Suggested fix
Set search_path = public when initializing the PGLite connection in ponder dev mode.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels