Repository navigation
fix: include public schema in PGLite search_path for raw SQL queries - #2299
Closed
tenderdeve wants to merge 1 commit into
Closed
tenderdeve wants to merge 1 commit into
tenderdeve wants to merge 1 commit into
Conversation
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
marked this pull request as ready for review
April 28, 2026 10:30
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
db.execute()return 0 rows in dev mode (PGLite) while Drizzle ORM queries work correctlySET search_pathonly included the namespace schema, excludingpublic. Drizzle ORM uses schema-qualified names internally so it worked, but raw SQL with unqualified table names failed silently.publicalongside the namespace schema in the in-migrationSET search_pathwhen the namespace is not alreadypublicsearch_pathpersistently after migration via PGLite'sexec()method (analogous to how the Postgres driver sets it per-connection viacreateReadonlyPool)File:
packages/core/src/database/index.tsFixes #2235
Test plan
db.execute(sql\SELECT * FROM "TableName"`)` — should return rows