Skip to content

fix: include public schema in PGLite search_path for raw SQL queries - #2299

Closed
tenderdeve wants to merge 1 commit into
ponder-sh:mainfrom
tenderdeve:fix/pglite-search-path
Closed

tenderdeve wants to merge 1 commit into
ponder-sh:mainfrom
tenderdeve:fix/pglite-search-path

Conversation

@tenderdeve

Copy link
Copy Markdown

Summary

  • Raw SQL queries via db.execute() return 0 rows in dev mode (PGLite) while Drizzle ORM queries work correctly
  • Root cause: The SET search_path only included the namespace schema, excluding public. Drizzle ORM uses schema-qualified names internally so it worked, but raw SQL with unqualified table names failed silently.
  • Fix (two parts):
    1. Include public alongside the namespace schema in the in-migration SET search_path when the namespace is not already public
    2. Set search_path persistently after migration via PGLite's exec() method (analogous to how the Postgres driver sets it per-connection via createReadonlyPool)

File: packages/core/src/database/index.ts

Fixes #2235

Test plan

  • Run ponder in dev mode (PGLite), execute raw SQL via db.execute(sql\SELECT * FROM "TableName"`)` — should return rows
  • Verify Drizzle ORM queries still work
  • Verify production Postgres mode is unaffected

Raw SQL queries via db.execute() return 0 rows in dev mode because
PGLite's search_path only included the namespace schema, excluding
public. Drizzle ORM worked because it uses schema-qualified names
internally.

Fix by including public in the SET search_path statement during
migration, and also setting it persistently via PGLite's exec()
after migration completes so it applies to all subsequent queries.

Fixes ponder-sh#2235
@tenderdeve
tenderdeve marked this pull request as ready for review April 28, 2026 10:30
@kyscott18

Copy link
Copy Markdown
Collaborator

I was not able to reproduced the described bug. If you are able to add a failing test case along with this PR, please re-open.

@kyscott18 kyscott18 closed this Jul 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PGLite search_path doesn't include public schema by default

2 participants